The monitor runs one thread at a time. Assuming you have T1-T10, 9 BLOCKED , and one is RUNNABLE . From time to time, the monitor selects a new thread to start. When this happens, the selected / 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 available to the other thread, you use wait() . In this case, the stream will be marked as WAITING until notify() ed. Thus, the thread that is waiting will not be executed by the monitor until then. For example, wait until the boxes are unloaded. The drawer loading box will notify me when this happens.
In other words, both BLOCKED and WAITING are inactive thread status, but WAITING thread cannot be RUNNABLE without first accessing BLOCKED . WAITING threads do not want to become active, while BLOCKED threads do want, but they cannot, because it is not their turn.
I think.
zxcvbnm Mar 28 '10 at 19:40 2010-03-28 19:40
source share