- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultithreading6.java
More file actions
Latest commit
47 lines (34 loc) · 1.1 KB
/
Copy pathmultithreading6.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
classthr4extendsThread {
publicvoidrun() {
while (true) {
System.out.println("thank you");
}
}
}
classthr5extendsThread {
publicvoidrun() {
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 (InterruptedExceptione) {
e.printStackTrace();
}
}
}
}
publicclassmultithreading6 {
publicstaticvoidmain(String[] args) {
thr4t1 = newthr4();
thr5t2 = newthr5();
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 (InterruptedExceptione) { // ye exception provide kr rha tha isiliye ise try & catch me likh diya ;;;
System.out.println(e);
}
t2.start();
}
}