CS 245
Oct. 13, 2008
Synch1.java from the class home page. Read through the
program documentation, so that you understand what the program
does. Compile and run it.
consumer.start() in
init(), exactly how many threads are executing?
Synch2.java from the class home page. Compare the
implementation of the Queue class there with the original
Queue class. This is the only change between the two programs.
Compile and run Synch2.java.
Synch2 class as well as two commented-out statements in that
class' init() method.
Predict what will happen if you allow those four statements to execute. Confirm your prediction by removing the comment symbols and compiling and running the program. Re-insert the comment symbols.
Queue class so that it can store up to five items.
To test your revised Queue class, modify the Producer
class so that it produces 20 integers and sleeps for only 100 ms.
between producing items.
You may find the following helpful if you've forgotten how to declare an array in Java:
int[] values = new int[5]; ... values[head] = v;