-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTut28.java
More file actions
51 lines (42 loc) · 829 Bytes
/
Tut28.java
File metadata and controls
51 lines (42 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package tutorial;
//threads
class Runno extends Thread {
@Override
public void run() {
for (int i = 0; i <= 10; i++) {
System.out.println("Running Thread1 : " + i);
}
}
}
class Runno2 extends Thread {
@Override
public void run() {
for (int i = 0; i <= 10; i++) {
System.out.println("Running Thread2 : " + i);
}
}
}
public class Tut28 {
public static void main(String[] args) {
// RunningThread();
// ThreadJoin();
}
// this method runs the thread but the see the output
public static void RunningThread() {
Runno n1 = new Runno();
Runno2 n2 = new Runno2();
n1.start();
n2.start();
}
public static void ThreadJoin() {
try {
Runno n1 = new Runno();
Runno2 n2 = new Runno2();
n1.start();
n1.join();
n2.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}