-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultithreading6.java
More file actions
47 lines (34 loc) · 1.1 KB
/
multithreading6.java
File metadata and controls
47 lines (34 loc) · 1.1 KB
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
class thr4 extends Thread {
public void run() {
while (true) {
System.out.println("thank you");
}
}
}
class thr5 extends Thread {
public void run() {
while (true) {
System.out.println("welcome");
try {
Thread.sleep(200); // .sleep() se perticular Thread kuch milliseconds ke liye sleep matlab run hona
// band hota hai
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public class multithreading6 {
public static void main(String[] args) {
thr4 t1 = new thr4();
thr5 t2 = new thr5();
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();
}
}