How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?

Technology CommunityCategory: JavaHow does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?
VietMX Staff asked 3 years ago

The JVM uses locks in conjunction with monitors. A monitor is basically a guardian that watches over a sequence of synchronized code and ensuring that only one thread at a time executes a synchronized piece of code. Each monitor is associated with an object reference. The thread is not allowed to execute the code until it obtains the lock.