-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultiThreading.java
50 lines (45 loc) · 1.05 KB
/
MultiThreading.java
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
package JavaPrograms;
class ABC extends Thread
{
public void show()
{
for(int i=0;i<5;i++)
{
System.out.println("hi");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public void run()
{
show();
}
}
public class MultiThreading {
public static void main(String arg[])
{
ABC obj1 = new ABC();
obj1.start();
Runnable r = new Runnable()
{
@Override
public void run()
{
for(int i=0;i<5;i++)
{
System.out.println("hello");
try {
Thread.sleep(1001);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
Thread t = new Thread(r);
t.start();
}
}