1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
|
|
7 |
|
import java.util.concurrent.*; |
36 |
|
warmup(); |
37 |
|
print = true; |
38 |
|
|
39 |
< |
int k = 1; |
40 |
< |
for (int i = 1; i <= maxn;) { |
39 |
> |
for (int k = 1, i = 1; i <= maxn;) { |
40 |
|
System.out.println("Consumers:" + i); |
41 |
|
oneTest(i, ITERS); |
42 |
|
if (i == k) { |
48 |
|
} |
49 |
|
|
50 |
|
pool.shutdown(); |
51 |
< |
} |
51 |
> |
} |
52 |
|
|
53 |
|
static void warmup() throws Exception { |
54 |
|
print = false; |
127 |
|
if (print) |
128 |
|
System.out.print("ArrayBlockingQueue(fair)"); |
129 |
|
oneRun(new ArrayBlockingQueue<Integer>(POOL_SIZE, true), n, fairIters); |
131 |
– |
|
130 |
|
} |
131 |
|
|
132 |
< |
static abstract class Stage implements Runnable { |
132 |
> |
abstract static class Stage implements Runnable { |
133 |
|
final int iters; |
134 |
|
final BlockingQueue<Integer> queue; |
135 |
|
final CyclicBarrier barrier; |
168 |
|
static class Consumer extends Stage { |
169 |
|
Consumer(BlockingQueue<Integer> q, CyclicBarrier b, int iters) { |
170 |
|
super(q, b, iters); |
173 |
– |
|
171 |
|
} |
172 |
|
|
173 |
|
public void run() { |