Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confused on how notify() works

 
Ai Ayumi
Greenhorn
Posts: 6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic