-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultithreading
More file actions
58 lines (50 loc) · 926 Bytes
/
Multithreading
File metadata and controls
58 lines (50 loc) · 926 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
58
//Understanding concept of multithreading in Java
class MyClass extends Thread
{
public void run()
{
for(Integer i=0;i<3;i++)
{
System.out.println("MyClass");
}
}
}
class MyClass1 extends Thread
{
public void run()
{
for(Integer i=0;i<3;i++)
{
System.out.println("MyClass1");
}
}
}
class threadingdemo {
threadingdemo()
{
MyClass obj1=new MyClass();
MyClass1 obj2=new MyClass1();
obj1.start();
obj2.start();
}
}
class multi implements Runnable
{
public void run()
{
System.out.println("This is a runnable interface after threading completed.");
}
}
class threadingusingrunnableinterface {
threadingusingrunnableinterface(){
multi m=new multi();
Thread t1=new Thread(m);
t1.start();
}
}
public class Threadingconcept {
public static void main(String[] args) {
threadingdemo obj = new threadingdemo();
threadingusingrunnableinterface obj1=new threadingusingrunnableinterface();
}
}