Basic HTML version of Foils prepared 17 Nov 97

Foil 12 Threads and Synchronization I

From Java Tutorial, July 1, 1996 CEWES Tutorial, CPS606, JSU Class CSC499 -- July 22-25 1997, Fall 97. by Nancy J. McCracken,Geoffrey C. Fox, Tom Scavo


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)



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998