This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Notify all Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Notify all" Watch "Notify all" New topic
Author

Notify all

Sudhanshu Mishra
Ranch Hand

Joined: May 28, 2011
Posts: 217

Hi all,
I have a question regarding notifyall(),wait() and notify().
What if i notify a thread which is not waiting on an objects lock,i.e what if the code with notify() runs before the code with wait()?
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

Sudhanshu Mishra wrote: what if the code with notify() runs before the code with wait()?

then nothing will happen.
For example:


thread2 will keep on waiting on lock1.

Piyush
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Notify all