wood burning stoves 2.0*
The moose likes Threads and Synchronization and the fly likes Confused on how notify() works Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Confused on how notify() works" Watch "Confused on how notify() works" New topic
Author

Confused on how notify() works

Ai Ayumi
Greenhorn

Joined: May 26, 2012
Posts: 6
It is said that when notify() is called, only one thread in waiting pool wakes up. Does that mean rest of the threads (all others in waiting) are stuck and don't get to wake up ever??
How do the other threads in waiting get a chance to finish their work then?

Thanks in advance!
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Ai Ayumi wrote:It is said that when notify() is called, only one thread in waiting pool wakes up. Does that mean rest of the threads (all others in waiting) are stuck and don't get to wake up ever??


It means they're stuck and don't get to wake up until notify() is called again, as many times as there are waiting threads, or until notifyAll() is called.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Confused on how notify() works