I would like to ask you a question related to multithreading in Java.
I have a monitor and multiple threads are eager to own it.
Also inside the critical section this.wait() is invoked based on some conditions.
AFAIK, the monitor has 2 sets of threads:
- entry set - where just arrived threads congregate and wait for their turn to own the monitor
- wait set - where
this.wait()threads that are waiting to be awakened
But how do they compete when notify/notifyAll is called?
Do threads from wait set have a priority in acquiring the monitor over threads in entry set or do they move to entry set?
Can I be sure that in case of notify the next executed thread will be one from the wait set?