Java: notify() vs. notifyAll() all over again
Posted
by Sergey Mikhanov
on Stack Overflow
See other posts from Stack Overflow
or by Sergey Mikhanov
Published on 2008-08-31T18:47:12Z
Indexed on
2010/05/21
3:40 UTC
Read the original article
Hit count: 670
java
|multithreading
If one google for "difference between notify() and notifyAll()" then a lot of explanations will pop up (leaving apart the javadoc paragraphs). It all boils down to the number of waiting threads being waken up: one in notify() and all in notifyAll().
However (if I do understand the difference between these methods right), only one thread is always selected for further monitor acquisition; in the first case the one selected by the VM, in the second case the one selected by the system thread scheduler. The exact selection procedures for both of them (in general case) are not known to the programmer.
What's is the useful difference between notify() and notifyAll() then? Am I missing something?
© Stack Overflow or respective owner