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

The wai() method

ravinderSingh singh
Ranch Hand

Joined: Nov 18, 2004
Posts: 41
When a thread invokes the wait() method on an object whose lock it holds, does the thread only release the lock on the object it invoked the wait method on, or does it release all the object locks it holds (assuming it holds other object locks)?

Henry Wong

Joined: Sep 28, 2004
Posts: 20521


The wait() method will only release the lock of the object that you are waiting on. However, it is possible to grab the same lock more than once, and the wait method will release *all* the grabs of the waiting lock.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: The wai() method
jQuery in Action, 3rd edition