• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where i use notifyall and where should i use notify

 
Pavan Rao
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where i use notifyall and where should i use notify
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where i use notifyall and where should i use notify


It depends on your requirement. Notify is for well, to notify only one thread which is waiting on a given object. And notifyall for notifying all the threads waiting on the given object. In notifyall you can't gurantee which thread will actually be picked by the JVM.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijitha Kumara wrote:In notifyall you can't gurantee which thread will actually be picked by the JVM.


I think you meant "In notify you can't gurantee which thread will actually be picked by the JVM."
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep Nitesh, Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic