5 |
|
*/ |
6 |
|
|
7 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
8 |
+ |
import static java.util.concurrent.TimeUnit.NANOSECONDS; |
9 |
|
import static java.util.concurrent.TimeUnit.SECONDS; |
10 |
|
|
11 |
|
import java.util.ArrayList; |
29 |
|
import java.util.concurrent.ThreadPoolExecutor; |
30 |
|
import java.util.concurrent.TimeoutException; |
31 |
|
import java.util.concurrent.TimeUnit; |
32 |
+ |
import java.util.concurrent.atomic.AtomicBoolean; |
33 |
|
import java.util.concurrent.atomic.AtomicInteger; |
34 |
+ |
import java.util.concurrent.atomic.AtomicLong; |
35 |
|
|
36 |
|
import junit.framework.Test; |
37 |
|
import junit.framework.TestSuite; |
108 |
|
final Runnable task = new CheckedRunnable() { |
109 |
|
public void realRun() { done.countDown(); }}; |
110 |
|
p.execute(task); |
111 |
< |
assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS)); |
111 |
> |
await(done); |
112 |
|
} |
113 |
|
} |
114 |
|
|
116 |
|
* delayed schedule of callable successfully executes after delay |
117 |
|
*/ |
118 |
|
public void testSchedule1() throws Exception { |
119 |
+ |
final CountDownLatch done = new CountDownLatch(1); |
120 |
|
final CustomExecutor p = new CustomExecutor(1); |
121 |
< |
try (PoolCleaner cleaner = cleaner(p)) { |
121 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
122 |
|
final long startTime = System.nanoTime(); |
119 |
– |
final CountDownLatch done = new CountDownLatch(1); |
123 |
|
Callable task = new CheckedCallable<Boolean>() { |
124 |
|
public Boolean realCall() { |
125 |
|
done.countDown(); |
129 |
|
Future f = p.schedule(task, timeoutMillis(), MILLISECONDS); |
130 |
|
assertSame(Boolean.TRUE, f.get()); |
131 |
|
assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); |
129 |
– |
assertTrue(done.await(0L, MILLISECONDS)); |
132 |
|
} |
133 |
|
} |
134 |
|
|
202 |
|
} |
203 |
|
|
204 |
|
/** |
205 |
< |
* scheduleAtFixedRate executes series of tasks at given rate |
205 |
> |
* scheduleAtFixedRate executes series of tasks at given rate. |
206 |
> |
* Eventually, it must hold that: |
207 |
> |
* cycles - 1 <= elapsedMillis/delay < cycles |
208 |
|
*/ |
209 |
|
public void testFixedRateSequence() throws InterruptedException { |
210 |
|
final CustomExecutor p = new CustomExecutor(1); |
211 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
212 |
|
for (int delay = 1; delay <= LONG_DELAY_MS; delay *= 3) { |
213 |
< |
long startTime = System.nanoTime(); |
214 |
< |
int cycles = 10; |
213 |
> |
final long startTime = System.nanoTime(); |
214 |
> |
final int cycles = 8; |
215 |
|
final CountDownLatch done = new CountDownLatch(cycles); |
216 |
< |
Runnable task = new CheckedRunnable() { |
216 |
> |
final Runnable task = new CheckedRunnable() { |
217 |
|
public void realRun() { done.countDown(); }}; |
218 |
< |
ScheduledFuture h = |
218 |
> |
final ScheduledFuture periodicTask = |
219 |
|
p.scheduleAtFixedRate(task, 0, delay, MILLISECONDS); |
220 |
< |
done.await(); |
221 |
< |
h.cancel(true); |
222 |
< |
double normalizedTime = |
223 |
< |
(double) millisElapsedSince(startTime) / delay; |
224 |
< |
if (normalizedTime >= cycles - 1 && |
225 |
< |
normalizedTime <= cycles) |
220 |
> |
final int totalDelayMillis = (cycles - 1) * delay; |
221 |
> |
await(done, totalDelayMillis + LONG_DELAY_MS); |
222 |
> |
periodicTask.cancel(true); |
223 |
> |
final long elapsedMillis = millisElapsedSince(startTime); |
224 |
> |
assertTrue(elapsedMillis >= totalDelayMillis); |
225 |
> |
if (elapsedMillis <= cycles * delay) |
226 |
|
return; |
227 |
+ |
// else retry with longer delay |
228 |
|
} |
229 |
< |
throw new AssertionError("unexpected execution rate"); |
229 |
> |
fail("unexpected execution rate"); |
230 |
|
} |
231 |
|
} |
232 |
|
|
233 |
|
/** |
234 |
< |
* scheduleWithFixedDelay executes series of tasks with given period |
234 |
> |
* scheduleWithFixedDelay executes series of tasks with given period. |
235 |
> |
* Eventually, it must hold that each task starts at least delay and at |
236 |
> |
* most 2 * delay after the termination of the previous task. |
237 |
|
*/ |
238 |
|
public void testFixedDelaySequence() throws InterruptedException { |
239 |
|
final CustomExecutor p = new CustomExecutor(1); |
240 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
241 |
|
for (int delay = 1; delay <= LONG_DELAY_MS; delay *= 3) { |
242 |
< |
long startTime = System.nanoTime(); |
243 |
< |
int cycles = 10; |
242 |
> |
final long startTime = System.nanoTime(); |
243 |
> |
final AtomicLong previous = new AtomicLong(startTime); |
244 |
> |
final AtomicBoolean tryLongerDelay = new AtomicBoolean(false); |
245 |
> |
final int cycles = 8; |
246 |
|
final CountDownLatch done = new CountDownLatch(cycles); |
247 |
< |
Runnable task = new CheckedRunnable() { |
248 |
< |
public void realRun() { done.countDown(); }}; |
249 |
< |
ScheduledFuture h = |
247 |
> |
final int d = delay; |
248 |
> |
final Runnable task = new CheckedRunnable() { |
249 |
> |
public void realRun() { |
250 |
> |
long now = System.nanoTime(); |
251 |
> |
long elapsedMillis |
252 |
> |
= NANOSECONDS.toMillis(now - previous.get()); |
253 |
> |
if (done.getCount() == cycles) { // first execution |
254 |
> |
if (elapsedMillis >= d) |
255 |
> |
tryLongerDelay.set(true); |
256 |
> |
} else { |
257 |
> |
assertTrue(elapsedMillis >= d); |
258 |
> |
if (elapsedMillis >= 2 * d) |
259 |
> |
tryLongerDelay.set(true); |
260 |
> |
} |
261 |
> |
previous.set(now); |
262 |
> |
done.countDown(); |
263 |
> |
}}; |
264 |
> |
final ScheduledFuture periodicTask = |
265 |
|
p.scheduleWithFixedDelay(task, 0, delay, MILLISECONDS); |
266 |
< |
done.await(); |
267 |
< |
h.cancel(true); |
268 |
< |
double normalizedTime = |
269 |
< |
(double) millisElapsedSince(startTime) / delay; |
270 |
< |
if (normalizedTime >= cycles - 1 && |
271 |
< |
normalizedTime <= cycles) |
266 |
> |
final int totalDelayMillis = (cycles - 1) * delay; |
267 |
> |
await(done, totalDelayMillis + cycles * LONG_DELAY_MS); |
268 |
> |
periodicTask.cancel(true); |
269 |
> |
final long elapsedMillis = millisElapsedSince(startTime); |
270 |
> |
assertTrue(elapsedMillis >= totalDelayMillis); |
271 |
> |
if (!tryLongerDelay.get()) |
272 |
|
return; |
273 |
+ |
// else retry with longer delay |
274 |
|
} |
275 |
< |
throw new AssertionError("unexpected execution rate"); |
275 |
> |
fail("unexpected execution rate"); |
276 |
|
} |
277 |
|
} |
278 |
|
|
388 |
|
* thread becomes active |
389 |
|
*/ |
390 |
|
public void testGetActiveCount() throws InterruptedException { |
391 |
+ |
final CountDownLatch done = new CountDownLatch(1); |
392 |
|
final ThreadPoolExecutor p = new CustomExecutor(2); |
393 |
< |
try (PoolCleaner cleaner = cleaner(p)) { |
393 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
394 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
369 |
– |
final CountDownLatch done = new CountDownLatch(1); |
395 |
|
assertEquals(0, p.getActiveCount()); |
396 |
|
p.execute(new CheckedRunnable() { |
397 |
|
public void realRun() throws InterruptedException { |
398 |
|
threadStarted.countDown(); |
399 |
|
assertEquals(1, p.getActiveCount()); |
400 |
< |
done.await(); |
400 |
> |
await(done); |
401 |
|
}}); |
402 |
< |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
402 |
> |
await(threadStarted); |
403 |
|
assertEquals(1, p.getActiveCount()); |
379 |
– |
done.countDown(); |
404 |
|
} |
405 |
|
} |
406 |
|
|
451 |
|
*/ |
452 |
|
public void testGetLargestPoolSize() throws InterruptedException { |
453 |
|
final int THREADS = 3; |
454 |
+ |
final CountDownLatch done = new CountDownLatch(1); |
455 |
|
final ThreadPoolExecutor p = new CustomExecutor(THREADS); |
456 |
< |
try (PoolCleaner cleaner = cleaner(p)) { |
456 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
457 |
|
final CountDownLatch threadsStarted = new CountDownLatch(THREADS); |
433 |
– |
final CountDownLatch done = new CountDownLatch(1); |
458 |
|
assertEquals(0, p.getLargestPoolSize()); |
459 |
|
for (int i = 0; i < THREADS; i++) |
460 |
|
p.execute(new CheckedRunnable() { |
461 |
|
public void realRun() throws InterruptedException { |
462 |
|
threadsStarted.countDown(); |
463 |
< |
done.await(); |
463 |
> |
await(done); |
464 |
|
assertEquals(THREADS, p.getLargestPoolSize()); |
465 |
|
}}); |
466 |
< |
assertTrue(threadsStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
466 |
> |
await(threadsStarted); |
467 |
|
assertEquals(THREADS, p.getLargestPoolSize()); |
444 |
– |
done.countDown(); |
468 |
|
} |
469 |
|
assertEquals(THREADS, p.getLargestPoolSize()); |
470 |
|
} |
474 |
|
* become active |
475 |
|
*/ |
476 |
|
public void testGetPoolSize() throws InterruptedException { |
477 |
+ |
final CountDownLatch done = new CountDownLatch(1); |
478 |
|
final ThreadPoolExecutor p = new CustomExecutor(1); |
479 |
< |
try (PoolCleaner cleaner = cleaner(p)) { |
479 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
480 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
457 |
– |
final CountDownLatch done = new CountDownLatch(1); |
481 |
|
assertEquals(0, p.getPoolSize()); |
482 |
|
p.execute(new CheckedRunnable() { |
483 |
|
public void realRun() throws InterruptedException { |
484 |
|
threadStarted.countDown(); |
485 |
|
assertEquals(1, p.getPoolSize()); |
486 |
< |
done.await(); |
486 |
> |
await(done); |
487 |
|
}}); |
488 |
< |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
488 |
> |
await(threadStarted); |
489 |
|
assertEquals(1, p.getPoolSize()); |
467 |
– |
done.countDown(); |
490 |
|
} |
491 |
|
} |
492 |
|
|
505 |
|
p.execute(new CheckedRunnable() { |
506 |
|
public void realRun() throws InterruptedException { |
507 |
|
threadStarted.countDown(); |
508 |
< |
done.await(); |
508 |
> |
await(done); |
509 |
|
}}); |
510 |
< |
assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
510 |
> |
await(threadStarted); |
511 |
|
assertEquals(1, p.getTaskCount()); |
512 |
|
assertEquals(0, p.getCompletedTaskCount()); |
513 |
|
for (int i = 0; i < TASKS; i++) { |
516 |
|
public void realRun() throws InterruptedException { |
517 |
|
threadStarted.countDown(); |
518 |
|
assertEquals(1 + TASKS, p.getTaskCount()); |
519 |
< |
done.await(); |
519 |
> |
await(done); |
520 |
|
}}); |
521 |
|
} |
522 |
|
assertEquals(1 + TASKS, p.getTaskCount()); |
578 |
|
* isTerminated is false before termination, true after |
579 |
|
*/ |
580 |
|
public void testIsTerminated() throws InterruptedException { |
581 |
+ |
final CountDownLatch done = new CountDownLatch(1); |
582 |
|
final ThreadPoolExecutor p = new CustomExecutor(1); |
583 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
584 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
562 |
– |
final CountDownLatch done = new CountDownLatch(1); |
563 |
– |
assertFalse(p.isTerminated()); |
585 |
|
p.execute(new CheckedRunnable() { |
586 |
|
public void realRun() throws InterruptedException { |
587 |
|
assertFalse(p.isTerminated()); |
588 |
|
threadStarted.countDown(); |
589 |
< |
done.await(); |
589 |
> |
await(done); |
590 |
|
}}); |
591 |
< |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
591 |
> |
await(threadStarted); |
592 |
> |
assertFalse(p.isTerminated()); |
593 |
|
assertFalse(p.isTerminating()); |
594 |
|
done.countDown(); |
595 |
|
try { p.shutdown(); } catch (SecurityException ok) { return; } |
602 |
|
* isTerminating is not true when running or when terminated |
603 |
|
*/ |
604 |
|
public void testIsTerminating() throws InterruptedException { |
605 |
+ |
final CountDownLatch done = new CountDownLatch(1); |
606 |
|
final ThreadPoolExecutor p = new CustomExecutor(1); |
607 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
608 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
586 |
– |
final CountDownLatch done = new CountDownLatch(1); |
609 |
|
assertFalse(p.isTerminating()); |
610 |
|
p.execute(new CheckedRunnable() { |
611 |
|
public void realRun() throws InterruptedException { |
612 |
|
assertFalse(p.isTerminating()); |
613 |
|
threadStarted.countDown(); |
614 |
< |
done.await(); |
614 |
> |
await(done); |
615 |
|
}}); |
616 |
< |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
616 |
> |
await(threadStarted); |
617 |
|
assertFalse(p.isTerminating()); |
618 |
|
done.countDown(); |
619 |
|
try { p.shutdown(); } catch (SecurityException ok) { return; } |
627 |
|
* getQueue returns the work queue, which contains queued tasks |
628 |
|
*/ |
629 |
|
public void testGetQueue() throws InterruptedException { |
630 |
+ |
final CountDownLatch done = new CountDownLatch(1); |
631 |
|
final ScheduledThreadPoolExecutor p = new CustomExecutor(1); |
632 |
< |
try (PoolCleaner cleaner = cleaner(p)) { |
632 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
633 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
611 |
– |
final CountDownLatch done = new CountDownLatch(1); |
634 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
635 |
|
for (int i = 0; i < tasks.length; i++) { |
636 |
|
Runnable r = new CheckedRunnable() { |
637 |
|
public void realRun() throws InterruptedException { |
638 |
|
threadStarted.countDown(); |
639 |
< |
done.await(); |
639 |
> |
await(done); |
640 |
|
}}; |
641 |
|
tasks[i] = p.schedule(r, 1, MILLISECONDS); |
642 |
|
} |
643 |
< |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
643 |
> |
await(threadStarted); |
644 |
|
BlockingQueue<Runnable> q = p.getQueue(); |
645 |
|
assertTrue(q.contains(tasks[tasks.length - 1])); |
646 |
|
assertFalse(q.contains(tasks[0])); |
625 |
– |
done.countDown(); |
647 |
|
} |
648 |
|
} |
649 |
|
|
651 |
|
* remove(task) removes queued task, and fails to remove active task |
652 |
|
*/ |
653 |
|
public void testRemove() throws InterruptedException { |
654 |
+ |
final CountDownLatch done = new CountDownLatch(1); |
655 |
|
final ScheduledThreadPoolExecutor p = new CustomExecutor(1); |
656 |
< |
try (PoolCleaner cleaner = cleaner(p)) { |
656 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
657 |
|
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
658 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
637 |
– |
final CountDownLatch done = new CountDownLatch(1); |
659 |
|
for (int i = 0; i < tasks.length; i++) { |
660 |
|
Runnable r = new CheckedRunnable() { |
661 |
|
public void realRun() throws InterruptedException { |
662 |
|
threadStarted.countDown(); |
663 |
< |
done.await(); |
663 |
> |
await(done); |
664 |
|
}}; |
665 |
|
tasks[i] = p.schedule(r, 1, MILLISECONDS); |
666 |
|
} |
667 |
< |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
667 |
> |
await(threadStarted); |
668 |
|
BlockingQueue<Runnable> q = p.getQueue(); |
669 |
|
assertFalse(p.remove((Runnable)tasks[0])); |
670 |
|
assertTrue(q.contains((Runnable)tasks[4])); |
675 |
|
assertTrue(q.contains((Runnable)tasks[3])); |
676 |
|
assertTrue(p.remove((Runnable)tasks[3])); |
677 |
|
assertFalse(q.contains((Runnable)tasks[3])); |
657 |
– |
done.countDown(); |
678 |
|
} |
679 |
|
} |
680 |
|
|
682 |
|
* purge removes cancelled tasks from the queue |
683 |
|
*/ |
684 |
|
public void testPurge() throws InterruptedException { |
685 |
+ |
final ScheduledFuture[] tasks = new ScheduledFuture[5]; |
686 |
+ |
final Runnable releaser = new Runnable() { public void run() { |
687 |
+ |
for (ScheduledFuture task : tasks) |
688 |
+ |
if (task != null) task.cancel(true); }}; |
689 |
|
final CustomExecutor p = new CustomExecutor(1); |
690 |
< |
ScheduledFuture[] tasks = new ScheduledFuture[5]; |
691 |
< |
for (int i = 0; i < tasks.length; i++) |
692 |
< |
tasks[i] = p.schedule(new SmallPossiblyInterruptedRunnable(), |
693 |
< |
LONG_DELAY_MS, MILLISECONDS); |
670 |
< |
try { |
690 |
> |
try (PoolCleaner cleaner = cleaner(p, releaser)) { |
691 |
> |
for (int i = 0; i < tasks.length; i++) |
692 |
> |
tasks[i] = p.schedule(new SmallPossiblyInterruptedRunnable(), |
693 |
> |
LONG_DELAY_MS, MILLISECONDS); |
694 |
|
int max = tasks.length; |
695 |
|
if (tasks[4].cancel(true)) --max; |
696 |
|
if (tasks[3].cancel(true)) --max; |
702 |
|
long count = p.getTaskCount(); |
703 |
|
if (count == max) |
704 |
|
return; |
705 |
< |
} while (millisElapsedSince(startTime) < MEDIUM_DELAY_MS); |
705 |
> |
} while (millisElapsedSince(startTime) < LONG_DELAY_MS); |
706 |
|
fail("Purge failed to remove cancelled tasks"); |
684 |
– |
} finally { |
685 |
– |
for (ScheduledFuture task : tasks) |
686 |
– |
task.cancel(true); |
687 |
– |
joinPool(p); |
707 |
|
} |
708 |
|
} |
709 |
|
|
726 |
|
}}; |
727 |
|
for (int i = 0; i < count; i++) |
728 |
|
p.execute(waiter); |
729 |
< |
assertTrue(threadsStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
729 |
> |
await(threadsStarted); |
730 |
|
assertEquals(poolSize, p.getActiveCount()); |
731 |
|
assertEquals(0, p.getCompletedTaskCount()); |
732 |
|
final List<Runnable> queuedTasks; |
1123 |
|
public void testTimedInvokeAny4() throws Exception { |
1124 |
|
final ExecutorService e = new CustomExecutor(2); |
1125 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1126 |
+ |
long startTime = System.nanoTime(); |
1127 |
|
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
1128 |
|
l.add(new NPETask()); |
1129 |
|
try { |
1130 |
< |
e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
1130 |
> |
e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
1131 |
|
shouldThrow(); |
1132 |
|
} catch (ExecutionException success) { |
1133 |
|
assertTrue(success.getCause() instanceof NullPointerException); |
1134 |
|
} |
1135 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1136 |
|
} |
1137 |
|
} |
1138 |
|
|
1142 |
|
public void testTimedInvokeAny5() throws Exception { |
1143 |
|
final ExecutorService e = new CustomExecutor(2); |
1144 |
|
try (PoolCleaner cleaner = cleaner(e)) { |
1145 |
+ |
long startTime = System.nanoTime(); |
1146 |
|
List<Callable<String>> l = new ArrayList<Callable<String>>(); |
1147 |
|
l.add(new StringTask()); |
1148 |
|
l.add(new StringTask()); |
1149 |
< |
String result = e.invokeAny(l, MEDIUM_DELAY_MS, MILLISECONDS); |
1149 |
> |
String result = e.invokeAny(l, LONG_DELAY_MS, MILLISECONDS); |
1150 |
|
assertSame(TEST_STRING, result); |
1151 |
+ |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
1152 |
|
} |
1153 |
|
} |
1154 |
|
|
1248 |
|
* timed invokeAll(c) cancels tasks not completed by timeout |
1249 |
|
*/ |
1250 |
|
public void testTimedInvokeAll6() throws Exception { |
1251 |
< |
final ExecutorService e = new CustomExecutor(2); |
1252 |
< |
try (PoolCleaner cleaner = cleaner(e)) { |
1253 |
< |
for (long timeout = timeoutMillis();;) { |
1251 |
> |
for (long timeout = timeoutMillis();;) { |
1252 |
> |
final CountDownLatch done = new CountDownLatch(1); |
1253 |
> |
final Callable<String> waiter = new CheckedCallable<String>() { |
1254 |
> |
public String realCall() { |
1255 |
> |
try { done.await(LONG_DELAY_MS, MILLISECONDS); } |
1256 |
> |
catch (InterruptedException ok) {} |
1257 |
> |
return "1"; }}; |
1258 |
> |
final ExecutorService p = new CustomExecutor(2); |
1259 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
1260 |
|
List<Callable<String>> tasks = new ArrayList<>(); |
1261 |
|
tasks.add(new StringTask("0")); |
1262 |
< |
tasks.add(Executors.callable(new LongPossiblyInterruptedRunnable(), TEST_STRING)); |
1262 |
> |
tasks.add(waiter); |
1263 |
|
tasks.add(new StringTask("2")); |
1264 |
|
long startTime = System.nanoTime(); |
1265 |
|
List<Future<String>> futures = |
1266 |
< |
e.invokeAll(tasks, timeout, MILLISECONDS); |
1266 |
> |
p.invokeAll(tasks, timeout, MILLISECONDS); |
1267 |
|
assertEquals(tasks.size(), futures.size()); |
1268 |
|
assertTrue(millisElapsedSince(startTime) >= timeout); |
1269 |
|
for (Future future : futures) |