-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultithreading.java
More file actions
28 lines (23 loc) · 827 Bytes
/
Copy pathMultithreading.java
File metadata and controls
28 lines (23 loc) · 827 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
public class Multithreading {
public static void main(String[] args) throws InterruptedException {
long startTime = System.currentTimeMillis();
//first Task
for(int i=1; i<=1000; i++){
System.out.print("*" + i);
}
System.out.println("\n * task completed");
//Second Task
for(int i=1; i<=1000; i++){
System.out.print("$" + i);
}
System.out.println("\n $ task completed");
//Third Task
for(int i=1; i<=1000; i++){
System.out.print("#" + i);
}
Thread.sleep(10000);
System.out.println("\n # task completed");
long endTime = System.currentTimeMillis();
System.out.printf("Total time taken: %d",(endTime-startTime));
}
}