• Post Reply Bookmark Topic Watch Topic
  • New Topic

which is better notify() or notifyAll() ??  RSS feed

 
Nada Mohammed
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
i know that notify() is responsible to wake up on of the threads waiting to access object and notifyAll() responsible to wake up all threads waiting to access same object but what it is the other different between these two methods ?? and which is better ??
Thanks a lot
 
Ganesh Ram
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the advantages with notifyAll is that you can wake up all the threads without discrimination. With notify , you make wake up the thread that is not waiting on the same lock.
So notifyall is better if there are multiple locks out there.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!