-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmul_thread.java
More file actions
46 lines (43 loc) · 1.04 KB
/
mul_thread.java
File metadata and controls
46 lines (43 loc) · 1.04 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
class Thread1 implements Runnable// step1
{
public void run()// step4
{
for (int i = 0; i < 10; i++) {
System.out.println("Thread 1: " + i);
}
}
}
class Thread2 implements Runnable// step1
{
public void run()// step4
{
for (int i = 0; i < 10; i++) {
System.out.println("Thread 2: " + i);
}
}
}
class Thread3 implements Runnable// step1
{
public void run()// step4
{
for (int i = 0; i < 10; i++) {
System.out.println("Thread 3: " + i);
}
}
}
class mul_thread {
public static void main(String args[]) {
Thread1 ob1 = new Thread1();
Thread2 ob2 = new Thread2();
Thread3 ob3 = new Thread3();
Thread t1 = new Thread(ob1);
Thread t2 = new Thread(ob2);
Thread t3 = new Thread(ob3);
t3.start();
t1.start();
t2.start();
for (int i = 0; i < 10; i++) {
System.out.println("Thread main's i= : " + i);
}
}
}