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.*; |
54 |
|
|
55 |
|
warmup(); |
56 |
|
print = true; |
57 |
< |
int k = 1; |
58 |
< |
for (int i = 1; i <= maxn;) { |
57 |
> |
for (int k = 1, i = 1; i <= maxn;) { |
58 |
|
System.out.println("Producers:" + i); |
59 |
|
oneTest(i, ITERS); |
60 |
|
if (i == k) { |
120 |
|
System.out.print("SynchronousQueue "); |
121 |
|
oneRun(new SynchronousQueue<Integer>(), n, iters); |
122 |
|
|
124 |
– |
|
123 |
|
Thread.sleep(100); // System.gc(); |
124 |
|
if (print) |
125 |
|
System.out.print("SynchronousQueue(fair) "); |
145 |
|
System.out.print("ArrayBlockingQueue(fair)"); |
146 |
|
oneRun(new ArrayBlockingQueue<Integer>(POOL_SIZE, true), n, fairIters); |
147 |
|
|
150 |
– |
|
148 |
|
} |
149 |
|
|
150 |
< |
static abstract class Stage implements Runnable { |
150 |
> |
abstract static class Stage implements Runnable { |
151 |
|
final int iters; |
152 |
|
final BlockingQueue<Integer> queue; |
153 |
|
final CyclicBarrier barrier; |
227 |
|
|
228 |
|
} |
229 |
|
|
233 |
– |
|
230 |
|
static void oneRun(BlockingQueue<Integer> q, int n, int iters) throws Exception { |
231 |
|
|
232 |
|
LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer(); |