-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselfmulti.java
More file actions
41 lines (35 loc) · 1017 Bytes
/
selfmulti.java
File metadata and controls
41 lines (35 loc) · 1017 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
/**
* Created by Dell on 12-09-2019.
*/
class thread1{
Thread t;
public void threadcall() {
t = Thread.currentThread();
t.setName("thread 1");
System.out.println("current thread " +t);
try {
for (int i = 5; i > 0; i--) {
System.out.println("Thread1: " + i);
Thread.sleep(5000);
}
} catch (InterruptedException e) {
System.out.println("Thread1 interrupted.");
}
System.out.println("Exiting thread1.");
}
}
public class selfmulti {
public static void main(String args[]) {
thread1 set = new thread1();
set.threadcall();
try {
for (int i = 5; i > 0; i--) {
System.out.println("Thread2: " + i);
Thread.sleep(700);
}
} catch (InterruptedException e) {
System.out.println("Thread2 interrupted.");
}
System.out.println("Exiting thread2.");
}
}