aspose file tools*
The moose likes Threads and Synchronization and the fly likes where i use notifyall and where should i use notify Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "where i use notifyall and where should i use notify" Watch "where i use notifyall and where should i use notify" New topic
Author

where i use notifyall and where should i use notify

Pavan Rao
Greenhorn

Joined: Apr 11, 2008
Posts: 9
where i use notifyall and where should i use notify
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

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.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

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."


apigee, a better way to API!
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Yep Nitesh, Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: where i use notifyall and where should i use notify