public class UnsynchronizedBuffer implements Buffer
1: //UnsynchronizedBuffer.java
2: //UnsynchronizedBuffer represents a single shared integer.
3:
4: public class UnsynchronizedBuffer implements Buffer
5: {
6: private int buffer = -1; // shared by producer and consumer threads
7:
8: // place value into buffer
9: public void set( int value )
10: {
11: System.err.println( Thread.currentThread().getName() +
12: " writes " + value );
13:
14: buffer = value;
15: }
16:
17: // return value from buffer
18: public int get()
19: {
20: System.err.println( Thread.currentThread().getName() +
21: " reads " + buffer );
22:
23: return buffer;
24: }
25:
26: } // end class UnsynchronizedBuffer
27: