-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultithreading5.java
More file actions
44 lines (32 loc) · 932 Bytes
/
multithreading5.java
File metadata and controls
44 lines (32 loc) · 932 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
//methods in multithreading
//join() method ko dekhenge
class thr2 extends Thread {
public void run() {
int i =0;
while (i<2000) {
System.out.println("thank you");
i++;
}
}
}
class thr3 extends Thread {
public void run() {
while (true) {
System.out.println("welcome");
}
}
}
public class multithreading5 {
public static void main(String[] args) {
thr2 t1 = new thr2();
thr3 t2 = new thr3();
t1.start();
try {
t1.join(); //// join likhnese pehle t1 run hoga ,,aur jab t1 ka kam KHATAM hoga to t2 run
//// hona shuru hoga
} catch (InterruptedException e) { // ye exception provide kr rha tha isiliye ise try & catch me likh diya ;;;
System.out.println(e);
}
t2.start();
}
}