The monitor executes one thread at a time. Assuming you have T1-T10 threads, 9 are BLOCKED
and one is RUNNABLE
. Every once in a while, the monitor picks a new thread to run. When that happens, the chosen/current thread, say T1, goes from RUNNABLE
to BLOCKED
. Then another thread, say, T2, goes from BLOCKED
to RUNNABLE
, becoming the current thread.
When one of the threads needs some information to be made available by another thread, you use wait()
. In that case, the thread will be flagged as WAITING
until it is notify()
ed. So, a thread that is waiting will not be executed by the monitor until then. An example would be, wait until there are boxes to be unloaded. The guy loading boxes will notify me when that happens.
In other words, both BLOCKED
and WAITING
are status of inactive threads, but a WAITING
thread cannot be RUNNABLE
without going to BLOCKED
first. WAITING
threads "don't want" to become active, whereas BLOCKED
threads "want" to, but can't, because it isn't their turn.
I think.