/**
   This program runs four threads that produce and consume data items
   that are stored in a shared buffer.
*/
public class ProducerConsumerTester
{
   public static void main(String[] args)
   {
      final int BUF_SIZE = 5;
      Buffer buf = new Buffer(BUF_SIZE);
      final int REPETITIONS = 20;

      ProducerRunnable p1 = new ProducerRunnable(
            buf, "p1", REPETITIONS);
      ConsumerRunnable c1 = new ConsumerRunnable(
            buf, "c1", REPETITIONS);
      ProducerRunnable p2 = new ProducerRunnable(
            buf, "p2", REPETITIONS);
      ConsumerRunnable c2 = new ConsumerRunnable(
            buf, "c2", REPETITIONS);

      Thread t1 = new Thread(p1);
      Thread t2 = new Thread(c1);
      Thread t3 = new Thread(p2);
      Thread t4 = new Thread(c2);

      t1.start();
      t2.start();
      t3.start();
      t4.start();
   }
}

