File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Synchronization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Synchronization" Watch "Synchronization" New topic


Sundeep Gupta

Joined: Feb 28, 2006
Posts: 13
Hi all,

Does a thread releases lock on all the objects when it calls wait() on an object, or only the lock of that specific object is released.

I think other object's lock will be held with thread.

Tell me whether i'm right or wrong


SCJP 5.0
Henry Wong

Joined: Sep 28, 2004
Posts: 20531

wait() will only release the lock on the object that you are waiting on.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: Synchronization
It's not a secret anymore!