This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread and Wait Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread and Wait" Watch "Thread and Wait" New topic

Thread and Wait

Riyaz Saiyed

Joined: Aug 13, 2006
Posts: 22
Is this statement correct..?

When a thread is waiting as a result of wait(), it release its lock.
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
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.


all events occur in real time
jQuery in Action, 3rd edition
subject: Thread and Wait
It's not a secret anymore!