01: /**
02: This program runs two threads in parallel.
03: */
04: public class ThreadTest
05: {
06: public static void main(String[] args)
07: {
08: Queue queue = new Queue(10);
09: final int REPETITIONS = 100;
10: Runnable run1 = new Producer("Hello, World!",
11: queue, REPETITIONS);
12: Runnable run2 = new Producer("Goodbye, World!",
13: queue, REPETITIONS);
14: Runnable run3 = new Consumer(queue, 2 * REPETITIONS);
15:
16: Thread thread1 = new Thread(run1);
17: Thread thread2 = new Thread(run2);
18: Thread thread3 = new Thread(run3);
19:
20: thread1.start();
21: thread2.start();
22: thread3.start();
23: }
24: }
25: