aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes why notifyAll do nothing 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 » Developer Certification (SCJD/OCMJD)
Bookmark "why notifyAll do nothing" Watch "why notifyAll do nothing" New topic
Author

why notifyAll do nothing

Paul Sun
Greenhorn

Joined: Aug 26, 2002
Posts: 19
Hi Everyone:
I use wait/notify to implement lock/unlock function. but the thread waitting to lock record is not notified. Why?
Thanks.
dennis hu
Ranch Hand

Joined: Aug 27, 2002
Posts: 40
Hi Paul:
You must confirm waint and notifyAll in a same object,otherwise it will failure.
~dennis ~
Paul Sun
Greenhorn

Joined: Aug 26, 2002
Posts: 19
What does mean "same object". I think thread A want to lock a record, but thread B lock it at that time, so A will wait until B unlock it and
notify A. Am I right?
dennis hu
Ranch Hand

Joined: Aug 27, 2002
Posts: 40
Hi Paul:
You are rignt!
If thread A want to lock a record that tread B had locked,thread A must wait until thread B unlock the record and notify it.
But what I mean "same objcet" is thread A and B must have the same reference of the object who contained wait() and notifyAll() but not means record.
~dennis~
Paul Sun
Greenhorn

Joined: Aug 26, 2002
Posts: 19
Hi Dennis:
Thanks. I put wait/notify method into LockManager, a object take charge of locking record, it can work so well.
Thank you.
Paul.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why notifyAll do nothing