-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTest3.java
56 lines (45 loc) · 1.21 KB
/
Test3.java
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
import java.util.Date;
/**
* Created by Michael on 3/3/2015.
*/
public class Test3 extends Thread
{
private int numThreadPairs;
public static Object syncObj = new Object();
public Test3()
{
numThreadPairs = 3;
}
public Test3(String[] args)
{
numThreadPairs = Integer.parseInt(args[0]);
}
public void run() {
long submissionTime = new Date().getTime();
int tid;
String name;
for (int i = 0; i < numThreadPairs; i++)
{
SysLib.exec(SysLib.stringToArgs("TestThread3a"));
SysLib.exec(SysLib.stringToArgs("TestThread3b"));
}
try
{
Thread.sleep(4000);
synchronized (Test3.syncObj)
{
Test3.syncObj.notifyAll();
}
}
catch(InterruptedException e) {}
for (int i = 0; i < numThreadPairs * 2; i++)
{
SysLib.join();
}
long completionTime = new Date().getTime();
SysLib.cout("Test3: =====================================" +
"\n\tturnaround time = " + (completionTime - submissionTime) +
"\n");
SysLib.exit();
}
}