Basic HTML version of Foils prepared Sept 21 1998

Foil 12 Threads and Synchronization I

From Java Tutorial 98- 4: Multi-Treading, Useful Java Classes, I/O and Networking NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken


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 Sat Nov 28 1998