- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultithreading5.java
More file actions
Latest commit
44 lines (32 loc) · 932 Bytes
/
Copy pathmultithreading5.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
classthr2extendsThread {
publicvoidrun() {
inti =0;
while (i<2000) {
System.out.println("thank you");
i++;
}
}
}
classthr3extendsThread {
publicvoidrun() {
while (true) {
System.out.println("welcome");
}
}
}
publicclassmultithreading5 {
publicstaticvoidmain(String[] args) {
thr2t1 = newthr2();
thr3t2 = newthr3();
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();
}
}