2 |
If a class has one or more synchronized methods, each object (instance) of the class has a monitor. The queue holds all threads waiting to execute a synchronized method.
-
A thread enters the queue by calling wait() inside the method or when another thread is already executing the method.
-
When a synchronized method returns, or when a method calls wait(), another thread may access the object.
-
As always, the scheduler chooses the highest-priority thread among those in the queue.
-
If a thread is put into the queue by calling wait(), it can't be scheduled for execution until some other thread calls notify().
|