If a thread must wait for the state of an object to change, it should call wait() inside a synchronized method.
-
void wait()
-
void wait( int timeout )
-
These methods cause the thread to wait until notified or until the timeout period expires, respectively.
-
The timeout argument is optional. If missing or zero, the thread waits until either notify() or notifyAll() is called. (See next foil.)
-
wait() is called by the thread owning the lock associated with a particular object; wait() releases this lock (atomically, i.e., safely)
|