-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultithread.java
More file actions
55 lines (48 loc) · 1.32 KB
/
multithread.java
File metadata and controls
55 lines (48 loc) · 1.32 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
48
49
50
51
52
53
54
55
class thread1 extends Thread {
public void run() {
int i;
try {
for (i = 0; i <= 10; i++) {
System.out.println(i + "nishad ...............................");
sleep(1000);
}
} catch (Exception e) {
System.out.println(e);
}
}
public void shu() {
int i;
try {
for (i = 0; i <= 10; i++) {
System.out.println(i
+ "--------------------------------------------------------------------------------");
// sleep(1000);
}
} catch (Exception e) {
System.out.println(e);
}
}
}
class thread2 extends Thread {
public void run() {
int i;
try {
for (i = 70; i <= 100; i = i + 2) {
System.out.println(i + ".........................shubhanshu ji");
sleep(500);
}
} catch (Exception e) {
System.out.println(e);
}
}
}
class multithread {
public static void main(String[] args) {
thread1 th1 = new thread1();
thread2 th2 = new thread2();
// th1.setName("shubhanshuji");
th1.start();
th2.start();
th1.shu();
}
}