What does the synchronized keyword mean and where would you use it?

1 answers

The synchronized keyword in Java defines a thread-safe operation and can be used on: instance methods, static methods and code blocks. The synchronization (thread-safety) is achieved by allowing a thread to acquire and release an intrinsic lock. While the thread owns the intrinsic lock, the other threads that will try to acquire it, will be blocked.

shilpigupta22 shilpigupta22 [Author] 8 months ago votes 0