1 |
|
/* |
2 |
|
* Written by Bill Scherer and Doug Lea with assistance from members |
3 |
< |
* of JCP JSR-166 Expert Group and released to the public domain. Use, |
4 |
< |
* modify, and redistribute this code in any way without |
5 |
< |
* acknowledgement. |
3 |
> |
* of JCP JSR-166 Expert Group and released to the public domain, as |
4 |
> |
* explained at http://creativecommons.org/licenses/publicdomain |
5 |
|
*/ |
6 |
|
|
7 |
|
import java.util.concurrent.*; |
31 |
|
patienceNanos = Long.parseLong(args[argc]); |
32 |
|
else if (option.equals("-r")) |
33 |
|
nReps = Integer.parseInt(args[argc]); |
34 |
< |
else |
34 |
> |
else |
35 |
|
maxThreads = Integer.parseInt(option); |
36 |
|
argc++; |
37 |
|
} |
73 |
|
} |
74 |
|
} |
75 |
|
|
76 |
< |
static void oneRun(int nThreads, long trialMillis, long patienceNanos) |
76 |
> |
static void oneRun(int nThreads, long trialMillis, long patienceNanos) |
77 |
|
throws Exception { |
78 |
|
System.out.printf("%4d threads", nThreads); |
79 |
|
System.out.printf("%9dms", trialMillis); |
89 |
|
long startTime = System.nanoTime(); |
90 |
|
start.countDown(); |
91 |
|
Thread.sleep(trialMillis); |
92 |
< |
for (int i = 0; i < nThreads; ++i) |
92 |
> |
for (int i = 0; i < nThreads; ++i) |
93 |
|
threads[i].interrupt(); |
94 |
|
long elapsed = System.nanoTime() - startTime; |
95 |
< |
for (int i = 0; i < nThreads; ++i) |
95 |
> |
for (int i = 0; i < nThreads; ++i) |
96 |
|
threads[i].join(); |
97 |
|
int iters = 0; |
98 |
|
long fails = 0; |
153 |
|
} |
154 |
|
} |
155 |
|
} |
157 |
– |
|