• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why notifyAll do nothing

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone:
I use wait/notify to implement lock/unlock function. but the thread waitting to lock record is not notified. Why?
Thanks.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul:
You must confirm waint and notifyAll in a same object,otherwise it will failure.
~dennis ~
 
Paul Sun
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic