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 |
|
/* |
18 |
|
* redistribute this code in any way without acknowledgement. |
19 |
|
*/ |
20 |
|
|
21 |
+ |
import java.util.*; |
22 |
|
import java.util.concurrent.*; |
23 |
|
import java.util.concurrent.locks.*; |
23 |
– |
import java.util.*; |
24 |
|
|
25 |
|
public final class CancelledFutureLoops { |
26 |
|
static final ExecutorService pool = Executors.newCachedThreadPool(); |
56 |
|
} |
57 |
|
|
58 |
|
final void test() throws Exception { |
59 |
< |
Future[] futures = new Future[nthreads]; |
59 |
> |
Future<?>[] futures = new Future<?>[nthreads]; |
60 |
|
for (int i = 0; i < nthreads; ++i) |
61 |
|
futures[i] = pool.submit(this); |
62 |
|
|
84 |
|
long endTime = System.nanoTime(); |
85 |
|
long time = endTime - timer.startTime; |
86 |
|
if (print) { |
87 |
< |
double secs = (double)(time) / 1000000000.0; |
87 |
> |
double secs = (double) time / 1000000000.0; |
88 |
|
System.out.println("\t " + secs + "s run time"); |
89 |
|
} |
90 |
|
|