The wait() Method
Home ] Up ] [ The wait() Method ] The notify() Method ] Other wait() Methods ] The notifyAll() Method ]

 

 

public final void wait() throws InterruptedException

Waits to be notified by another thread of a change in this object. The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution. This method should only be called by a thread that is the owner of this object's monitor.

The wait() method:

  • Throws IllegalMonitorStateException if the current thread is not the owner of the object's monitor.
  • Throws InterruptedException if another thread has interrupted this thread.
 
The page was last updated February 19, 2008