Basic HTML version of Foils prepared June 5 99

Foil 63 More about synchronization

From Java Language in the Computer Science Curriculum ADMI Tutorial Duluth Minnesota -- June 3 99. by Geoffrey C. Fox


1 Often, one thread is producing some data, while another thread wants to use it.
2 A flag variable is introduced that both threads can check.
3 If the data is not ready (flag is false), the consuming thread can call the method wait ( ), which causes it to be suspended until some other event occurs.
4 When the producing thread has some data, it can set the flag to be true and call the method notify ( ), which causes an event that will "wake up" one of the suspended threads.
5 If the user doesn't get the logic right, there are possibilities for deadlock or other forms of non-progress.

in Table To:


© 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 Jun 5 1999