This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes notify vs notifyAll Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "notify vs notifyAll" Watch "notify vs notifyAll" New topic
Author

notify vs notifyAll

P Ventura
Ranch Hand

Joined: Jan 24, 2007
Posts: 42
Please, someone clarify differences between notify and notifyAll.
I can't understand, they're similar!


Objective: SCJP 1.5<br /><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html" target="_blank" rel="nofollow">API</a><br /> <blockquote><font size="1" face="Verdana, Arial">code:</font><hr><pre><font size="2"><br />Double n1 = Double.NaN; Double n2 = Double.NaN;<br /> n1.equals(n2) // true even though Double.NaN != Double.NaN<br />-0.0 == +0.0; // true<br />Double n1 = -0.0;Double n2 = +0.0;<br />n1.equals(n2) // false even though -0.0 == +0.0<br /></font></pre><hr></blockquote>
Kelvin Chenhao Lim
Ranch Hand

Joined: Oct 20, 2007
Posts: 513
More than one thread can wait on an object at any given time. When you call an object's notify() method, only one of those waiting threads will be woken (and you can't choose which one). On the other hand, if you call an object's notifyAll() method, all of those waiting threads will be woken.


SCJP 5.0
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: notify vs notifyAll
 
Similar Threads
Threads, wait, notify and deadlocks.
SCJP 1.5 topic
Exam Topics update
Runnable object use
Difference beteween notify and notifyAll.