Yurttas/PL/OOL/Java/F/07/03/T03.java
Jump to navigation
Jump to search
1/**
2 * Copyright(C) 1998
3 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for EDUCATIONAL purposes
7 * and without fee is hereby granted provided that this
8 * copyright notice appears in all copies.
9 *
10 * @date : January 1, 1998.
11 * @author : Salih Yurttas.
12 */
13
14
15public class T03 {
16
17 public static void main(String[] args) {
18 final int INTERVAL1=10000;
19 final int INTERVAL2=8000;
20 final int INTERVAL3=6000;
21
22 Thread t1 = new SleeperThread(INTERVAL1);
23 Thread t2 = new SleeperThread(INTERVAL2);
24 Thread t3 = new SleeperThread(INTERVAL3);
25
26 t1.start();
27 t2.start();
28 t3.start();
29
30 System.out.println("Waiting for Thread 1 to finish");
31
32 try {
33 t1.join();
34 }
35 catch(InterruptedException joinExcept) {
36 System.out.println(" Join exception ");
37 }
38
39 System.out.println("Thread 1 has finished");
40
41 System.out.println("Waiting for Thread 2 to finish");
42
43 try {
44 t2.join();
45 }
46 catch(InterruptedException joinExcept) {
47 System.out.println(" Join exception ");
48 }
49
50 System.out.println("Thread 2 has finished");
51
52 System.out.println("Waiting for Thread 3 to finish");
53
54 try {
55 t3.join();
56 }
57 catch(InterruptedException joinExcept) {
58 System.out.println(" Join exception ");
59 }
60
61 System.out.println("Thread 3 has finished");
62 }
63
64}