6 |
|
|
7 |
|
import java.util.*; |
8 |
|
import java.util.concurrent.*; |
9 |
– |
import java.util.concurrent.locks.*; |
9 |
|
import java.util.concurrent.atomic.*; |
10 |
+ |
import java.util.concurrent.locks.*; |
11 |
|
|
12 |
|
public class ConcurrentQueueLoops { |
13 |
|
static final ExecutorService pool = Executors.newCachedThreadPool(); |
117 |
|
} |
118 |
|
|
119 |
|
static void oneRun(Class<?> klass, int n) throws Exception { |
120 |
< |
Queue<Integer> q = (Queue<Integer>) klass.newInstance(); |
120 |
> |
Queue<Integer> q = |
121 |
> |
(Queue<Integer>) klass.getConstructor().newInstance(); |
122 |
|
LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer(); |
123 |
|
CyclicBarrier barrier = new CyclicBarrier(n + 1, timer); |
124 |
|
ArrayList<Future<Integer>> results = new ArrayList<Future<Integer>>(n); |