-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunnable_Demo.java
More file actions
57 lines (48 loc) · 957 Bytes
/
Copy pathRunnable_Demo.java
File metadata and controls
57 lines (48 loc) · 957 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class A implements Runnable
{
public void run()
{
for(int i=0; i<20; i++)
{
System.out.println("Hi");
try
{
Thread.sleep(10);
}
catch(InterruptedException e)
{
System.out.println(e);
}
}
}
}
class B implements Runnable
{
public void run()
{
for(int i=0; i<20; i++)
{
System.out.println("Hello");
try
{
Thread.sleep(10);
}
catch(InterruptedException e)
{
System.out.println(e);
}
}
}
}
public class Runnable_Demo
{
public static void main(String[] args)
{
Runnable obj1=new A();
Runnable obj2=new B();
Thread t1=new Thread(obj1);
Thread t2=new Thread(obj2);
t1.start();
t2.start();
}
}