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(); |
21 |
|
public static void main(String[] args) throws Exception { |
22 |
|
int maxStages = 100; |
23 |
|
int work = 1024; |
24 |
< |
Class klass = null; |
24 |
> |
Class<?> klass = null; |
25 |
|
if (args.length > 0) { |
26 |
|
try { |
27 |
|
klass = Class.forName(args[0]); |
116 |
|
} |
117 |
|
} |
118 |
|
|
119 |
< |
static void oneRun(Class klass, int n) throws Exception { |
119 |
> |
static void oneRun(Class<?> klass, int n) throws Exception { |
120 |
|
Queue<Integer> q = (Queue<Integer>) klass.newInstance(); |
121 |
|
LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer(); |
122 |
|
CyclicBarrier barrier = new CyclicBarrier(n + 1, timer); |