forked from dharmanshu1921/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultithread.java
More file actions
50 lines (50 loc) · 616 Bytes
/
Copy pathMultithread.java
File metadata and controls
50 lines (50 loc) · 616 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
class Babe implements Runnable
{
Thread t;
String Tname;
Babe(String name)
{
Tname=name;
t=new Thread(this,Tname);
System.out.println(t);
}
public void run()
{
try
{
for(int i=0;i<5;i++)
{
System.out.println(Tname +i);
Thread.sleep(1000);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
class Multithread
{
public static void main(String args[])
{
Babe t1=new Babe("One");
Babe t2=new Babe("Two");
Babe t3=new Babe("Three");
t1.t.start();
t2.t.start();
t3.t.start();
try
{
for(int i=0;i<5;i++)
{
//System.out.println("Parent Thread"+i);
Thread.sleep(1000);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}