Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Basic question on wait & notify  RSS feed

 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this true ?

When a thread accessing a synchronized method() executes "wait()" in that method then that particular synchronized method can be accessed by some other thread even though the first thread dint come out of the sync method .....
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the method calls wait() on the object it belongs to, yes. When wait() is called, the monitor lock for the object held by the thread is released. When it gets notified, it attempts to reacquire the lock and if successful, exits the wait() method back into the synchronized method/block.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!