Source of ThreadTester.java


  1: /**
  2:    This program runs two threads in parallel.
  3: */
  4: public class ThreadTester
  5: {
  6:    public static void main(String[] args)
  7:    {
  8:       BoundedQueue<String> queue = new BoundedQueue<String>(10);
  9:       queue.setDebug(true);
 10:       final int GREETING_COUNT = 100;
 11:       Runnable run1 = new Producer("Hello, World!", 
 12:             queue, GREETING_COUNT);
 13:       Runnable run2 = new Producer("Goodbye, World!", 
 14:             queue, GREETING_COUNT);
 15:       Runnable run3 = new Consumer(queue, 2 * GREETING_COUNT);
 16:       
 17:       Thread thread1 = new Thread(run1);
 18:       Thread thread2 = new Thread(run2);
 19:       Thread thread3 = new Thread(run3);

 21:       thread1.start();
 22:       thread2.start();
 23:       thread3.start();
 24:    }
 25: }