public void run() {
   producer.getReady();
   MyBlockingQueue<Integer> buffer = producer.getBuffer();
   Integer item = buffer.take();
   while (item != null) {
     System.out.println(this + " fetches " + item + ".");
     Thread.yield();
     item = buffer.take();
   }
 }
 public static void main(String[] args) throws InterruptedException {
   final int NUM = 10;
   Producer producer = new Producer(10);
   Consumer[] consumers = new Consumer[NUM];
   for (int i = 0; i < NUM; i++) {
     consumers[i] = new Consumer(producer);
   }
   System.out.println("\t== START ==");
   producer.start();
   for (int i = 0; i < NUM; i++) {
     consumers[i].join();
   }
   System.out.println("\t== OVER ==");
 }