Basic HTML version of Foils prepared 18 May 97

Foil 10 Threads and Synchronization - notify()

From Java Tutorial - Spring 1997 Part 4: Multithreading, useful Java classes, I/O, Networking, and the future Peking Tutorial, Web Certificate -- Spring-Summer 1997. by Nancy J. McCracken,Geoffrey C. Fox


Threadsafe Variables
void notify()
void notifyAll()
  • The notify() and notifyall() methods are part of the Object class, and hence available for every object.
  • These methods must be called from a synchronized method.
  • These methods simply notifies a thread that is waiting.
notify() notifies the thread associated with given synchronization object that has been waiting the longest time
notifyall() notifies all threads associated with given object
One can mark a variable as "threadsafe" to notify the compiler that only one thread will be modifying this variable.



© 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 Thu Jan 8 1998