-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmthreadr.java
More file actions
46 lines (42 loc) · 1.04 KB
/
mthreadr.java
File metadata and controls
46 lines (42 loc) · 1.04 KB
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
//creating class which implements Runnable interface
class AreaSquare implements Runnable
{
//run method to create thread
public void run()
{
int[] len = {5,6,7};
for (int i = 0; i< len.length; i++ )
{
int area = len[i] * len[i];
System.out.println("Area is " + area);
}
}
}
class PeriSquare implements Runnable
{
public void run()
{
int[] len = {7,8,9};
for (int i = 0; i< len.length; i++ )
{
int perimeter = 4 * len[i];
System.out.println("Perimeter is " + perimeter);
}
}
}
class ThreadTesting
{
//main method
public static void main(String args[])
{
//creating class object
AreaSquare a = new AreaSquare();
//thread object
Thread thread1 = new Thread(a);
//invoking run method
thread1.start();
PeriSquare b = new PeriSquare();
Thread thread2 = new Thread(b);
thread2.start();
}
}