/** * A class to demonstrate a bounded buffer in use. * A thread trying to put to a full buffer or take from an empty one will block. * * Taken from _Concepts in Programming Languages_ by John Mitchell * Comments by Scot Drysdale * @author John Mitchell */ public class BoundedBufferTest { public static void main(String[] args) { BoundedBuffer buffer = new BoundedBuffer(5); // buffer has size 5 Producer prod = new Producer(buffer); Consumer cons1 = new Consumer(buffer); Consumer cons2 = new Consumer(buffer); prod.start(); cons1.start(); cons2.start(); try { prod.join(); cons1.interrupt(); cons2.interrupt(); } catch (InterruptedException e) { } System.out.println("End of Program"); } }