Concurrent Programming (19530-V)Dr. Richard S. Hall WS 01/02- Übung 5 -Assigned: 27.11.2001Due: 4.12.2001 |
1. Exercise a) How is a monitor similar to a Java class? How is it different?b) What is the purpose of condition variables? c) What must be true before a thread can call wait() or notify()? d) What two things happen when a thread calls wait()? e) Why do we usually use condition variables within a while loop? 2. Exercise The solution to the musuem example from Übung 2 is reproduced below; identify which of the processes, EAST, WEST, CONTROL, and DIRECTOR, should be threads and which should be monitors. Provide an implementation of the monitors. const N=2
3. Exercise FSP allows multiple processes to synchronize on a single action. A set of processes with the action sync in their alphabets must all perform this action before any of them can proceed. Implement a monitor called Barrier in Java with a sync method that ensures that N threads must call sync before any of them can proceed.
|