Two Laptop Bag*
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 Android Security Essentials Live Lessons this week in the Android 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.

 
jQuery in Action, 2nd edition
 
subject: Confused on how notify() works
 
Similar Threads
Thread states, notify, notifyAll, wait
Interview question
Clarification of notify( ) vs. notifyAll( )
notify() vs notifyAll()
calling notify() multiple times