Yurttas/PL/OOL/Java/F/07/01/T00.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 T00 extends Thread {
16
17 public static void main (String[] args) {
18 int delay1,
19 delay2;
20
21 switch(args.length) {
22 case 2 : delay1 = Integer.parseInt(args[0]);
23 delay2 = Integer.parseInt(args[1]);
24 break;
25 default: delay1 = 10;
26 delay2 = 60;
27 }
28
29 T00 thread1 = new T00("Thread 1",
30 delay1);
31 T00 thread2 = new T00(" Thread 2",
32 delay2);
33
34 thread1.start();
35 thread2.start();
36 }
37
38 private static final int N=16;
39
40 private String label;
41 private int delay;
42
43 public T00(final String id,
44 final int d) {
45 super(id);
46 label = id;
47 delay = d;
48 }
49
50 public void run() {
51 try {
52 for(int i=0; i<N; i++) {
53 System.out.println(label + ": " + i );
54 Thread.sleep(delay);
55 }
56 }
57 catch(InterruptedException iE) {
58 return;
59 }
60 }
61
62}