373 |
|
final ThreadPoolExecutor p = new ScheduledThreadPoolExecutor(THREADS); |
374 |
|
final CountDownLatch threadsStarted = new CountDownLatch(THREADS); |
375 |
|
final CountDownLatch done = new CountDownLatch(1); |
376 |
< |
try (PoolCleaner cleaner = cleaner(p)) { |
376 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
377 |
|
assertEquals(0, p.getLargestPoolSize()); |
378 |
|
for (int i = 0; i < THREADS; i++) |
379 |
|
p.execute(new CheckedRunnable() { |
382 |
|
await(done); |
383 |
|
assertEquals(THREADS, p.getLargestPoolSize()); |
384 |
|
}}); |
385 |
< |
assertTrue(threadsStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
385 |
> |
await(threadsStarted); |
386 |
|
assertEquals(THREADS, p.getLargestPoolSize()); |
387 |
– |
done.countDown(); |
387 |
|
} |
388 |
|
assertEquals(THREADS, p.getLargestPoolSize()); |
389 |
|
} |
396 |
|
final ThreadPoolExecutor p = new ScheduledThreadPoolExecutor(1); |
397 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
398 |
|
final CountDownLatch done = new CountDownLatch(1); |
399 |
< |
try (PoolCleaner cleaner = cleaner(p)) { |
399 |
> |
try (PoolCleaner cleaner = cleaner(p, done)) { |
400 |
|
assertEquals(0, p.getPoolSize()); |
401 |
|
p.execute(new CheckedRunnable() { |
402 |
|
public void realRun() throws InterruptedException { |
404 |
|
assertEquals(1, p.getPoolSize()); |
405 |
|
await(done); |
406 |
|
}}); |
407 |
< |
assertTrue(threadStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
407 |
> |
await(threadStarted); |
408 |
|
assertEquals(1, p.getPoolSize()); |
410 |
– |
done.countDown(); |
409 |
|
} |
410 |
|
} |
411 |
|
|
652 |
|
}}; |
653 |
|
for (int i = 0; i < count; i++) |
654 |
|
p.execute(waiter); |
655 |
< |
assertTrue(threadsStarted.await(LONG_DELAY_MS, MILLISECONDS)); |
655 |
> |
await(threadsStarted); |
656 |
|
assertEquals(poolSize, p.getActiveCount()); |
657 |
|
assertEquals(0, p.getCompletedTaskCount()); |
658 |
|
final List<Runnable> queuedTasks; |