import java.util.*; // Test class that produces integers and pushes // them into a BoundedQueue: public class Producer extends Thread { private BoundedQueue _queue; private int _n; private int _maxSleep = 100; public Producer(BoundedQueue queue, int n) { _queue = queue; _n = n; } public void run() { for(int i = 0; i<_n; ++i) { _queue.push(new Integer(i)); System.out.println("produce: " + i); try { sleep((int)(Math.random()*_maxSleep)); } catch (InterruptedException e) {} } } }