-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTasks.java
More file actions
52 lines (46 loc) · 1.45 KB
/
Copy pathTasks.java
File metadata and controls
52 lines (46 loc) · 1.45 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
47
48
49
50
51
52
public class Tasks {
public static class FirstTask extends Thread{
@Override
public void run() {
//first Task
for(int i=1; i<=1000; i++){
System.out.print("*" + i);
}
System.out.println("\n * task completed");
}
}
public static class SecondTask extends Thread{
@Override
public void run() {
//Second Task
for(int i=1; i<=1000; i++){
System.out.print("$" + i);
}
System.out.println("\n $ task completed");
}
}
public static class ThirdTask extends Thread{
@Override
public void run() {
//Third Task
for(int i=1; i<=1000; i++){
System.out.print("#" + i);
}
System.out.println("\n # task completed");
}
}
public static void main(String[] args) {
long startTime = System.currentTimeMillis();
FirstTask t1 = new FirstTask();
SecondTask t2 = new SecondTask();
ThirdTask t3 = new ThirdTask();
System.out.println("\nStarting first Thread");
t1.start();
System.out.println("\nStarting Second Thread");
t2.start();
System.out.println("\nStarting Third Thread");
t3.start();
long endTime = System.currentTimeMillis();
System.out.println("Total time taken is: " + (endTime- startTime) + "milliseconds");
}
}