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

Thread and Wait  RSS feed

 
Riyaz Saiyed
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,
Is this statement correct..?

When a thread is waiting as a result of wait(), it release its lock.
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, wait() causes the thread that calls it to give up its lock.

Otherwise a notify() could never be called, as notify can only be called in a synchronized block or method. And the thread that calls notify() must have the lock on that object. If it were the case, that wait() kept its lock, no other thread could ever get it.



Yours,
Bu.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!