-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
24 lines (19 loc) · 724 Bytes
/
Test.java
File metadata and controls
24 lines (19 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import multithread.*;
import dosomething.*;
class Test {
public static void main(String[] args) {
SharedContainer<Double> sharedContainer = new SharedContainer<>();
DoSomething<Double> doSomething = new DoSomething<>(sharedContainer);
CustomThread myThread1 = new CustomThread("thread_1", doSomething);
CustomThread myThread2 = new CustomThread("thread_2", doSomething);
try {
// join allows one thread to wait until another thread completes its execution
myThread1.start();
myThread1.join();
myThread2.start();
myThread2.join();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}