-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreads.java
More file actions
41 lines (40 loc) · 1.06 KB
/
Threads.java
File metadata and controls
41 lines (40 loc) · 1.06 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
class data extends Thread{
public void run(){
for(int i=1;i<=5;i++){
char ch=(char)(96+i);
System.out.println(ch);
try{ Thread.sleep(5000);
}
catch (InterruptedException e){};
}
}
}
class naturalnum extends Thread{
public void run(){
for(int i=1;i<=5;i++){
System.out.println(i);
try{ Thread.sleep(3000);
}
catch (InterruptedException e){};
}
}
}
class Main{
public static void main(String[] args)throws InterruptedException {
data d1=new data();
naturalnum n1=new naturalnum();
d1.start();
n1.start();
if(d1.isAlive()){
System.out.println("Running");
}
d1.join();
n1.join();
System.out.println("End of Statement");
if(n1.isAlive()){
System.out.println("Running");
}else{
System.out.println("Thread id dead");
}
}
}