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
Latest commit
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
classBabeimplementsRunnable
{
Threadt;
StringTname;
Babe(Stringname)
{
Tname=name;
t=newThread(this,Tname);
System.out.println(t);
}
publicvoidrun()
{
try
{
for(inti=0;i<5;i++)
{
System.out.println(Tname +i);
Thread.sleep(1000);
}
}
catch(Exceptione)
{
System.out.println(e);
}
}
}
classMultithread
{
publicstaticvoidmain(Stringargs[])
{
Babet1=newBabe("One");
Babet2=newBabe("Two");
Babet3=newBabe("Three");
t1.t.start();
t2.t.start();
t3.t.start();
try
{
for(inti=0;i<5;i++)
{
//System.out.println("Parent Thread"+i);
Thread.sleep(1000);
}
}
catch(Exceptione)
{
System.out.println(e);
}
}
}