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

Solution:

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.

0 answers