import java.util.*; // Test class that consumeds integers from // a BoundedQueue: public class Consumer extends Thread { private BoundedQueue _queue; private int _n; private String _name; private int _maxSleep = 50; public Consumer(BoundedQueue queue, int n, String name) { _queue = queue; _n = n; _name = name; } public Consumer(BoundedQueue queue, int n) { _queue = queue; _n = n; _name = "consumer"; } public void run() { for(int i = 0; i<_n; ++i) { Object obj = _queue.pop(); System.out.println(_name+ " consumes : " + obj); try { sleep((int)(Math.random()*_maxSleep)); } catch (InterruptedException e) {} } } }