18 |
|
* redistribute this code in any way without acknowledgement. |
19 |
|
*/ |
20 |
|
|
21 |
< |
import java.util.concurrent.*; |
22 |
< |
import java.util.concurrent.locks.*; |
23 |
< |
import java.util.*; |
21 |
> |
import java.util.concurrent.Callable; |
22 |
> |
import java.util.concurrent.CyclicBarrier; |
23 |
> |
import java.util.concurrent.ExecutorService; |
24 |
> |
import java.util.concurrent.Executors; |
25 |
> |
import java.util.concurrent.Future; |
26 |
> |
import java.util.concurrent.locks.ReentrantLock; |
27 |
|
|
28 |
|
public final class CancelledFutureLoops { |
29 |
|
static final ExecutorService pool = Executors.newCachedThreadPool(); |
47 |
|
pool.shutdown(); |
48 |
|
} |
49 |
|
|
50 |
< |
static final class FutureLoop implements Callable { |
50 |
> |
static final class FutureLoop implements Callable<Object> { |
51 |
|
private int v = rng.next(); |
52 |
|
private final ReentrantLock lock = new ReentrantLock(); |
53 |
|
private final LoopHelpers.BarrierTimer timer = new LoopHelpers.BarrierTimer(); |
59 |
|
} |
60 |
|
|
61 |
|
final void test() throws Exception { |
62 |
< |
Future[] futures = new Future[nthreads]; |
62 |
> |
Future<?>[] futures = new Future<?>[nthreads]; |
63 |
|
for (int i = 0; i < nthreads; ++i) |
64 |
|
futures[i] = pool.submit(this); |
65 |
|
|