// A fully synchronized BoundedQueue. Adds // synchronization to the BoundedQueue class. // Note: This implementation is buggy and is // shown as an example only. public class SyncBoundedQueue extends BoundedQueue { public SyncBoundedQueue(int size) { super(size); } synchronized public boolean isEmpty() { return super.isEmpty(); } synchronized public boolean isFull() { return super.isFull(); } synchronized public int getCount() { return super.getCount(); } synchronized public void push(Object e) { super.push(e); } synchronized public void pop(Object e) { super.pop(); } // Test driver (note: shows problems with this implementation) public static void main(String argv[] ) { SyncBoundedQueue queue = new SyncBoundedQueue(5); new Producer(queue,10).start(); new Consumer(queue,10).start(); } }