jQuery in Action, 2nd edition
The moose likes Threads and Synchronization and the fly likes which is better notify() or notifyAll() ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "which is better notify() or notifyAll() ??" Watch "which is better notify() or notifyAll() ??" New topic
Author

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

Nada Mohammed
Ranch Hand

Joined: Sep 22, 2000
Posts: 30
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

Joined: Jul 20, 2001
Posts: 33
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: which is better notify() or notifyAll() ??
 
Similar Threads
Difference between Notify and NotifyAll
question from javacross simulation!! Help!
Thread synchronization problem
Removing entry from HashMap when storing ReentrantLocks safely
about monitors