402 |
|
new ThreadPoolExecutor(1, 1, |
403 |
|
LONG_DELAY_MS, MILLISECONDS, |
404 |
|
new ArrayBlockingQueue<Runnable>(10)); |
405 |
< |
final CountDownLatch threadStarted = new CountDownLatch(1); |
406 |
< |
final CountDownLatch done = new CountDownLatch(1); |
407 |
< |
try { |
405 |
> |
try (PoolCleaner cleaner = cleaner(p)) { |
406 |
> |
final CountDownLatch threadStarted = new CountDownLatch(1); |
407 |
> |
final CountDownLatch done = new CountDownLatch(1); |
408 |
|
assertEquals(0, p.getTaskCount()); |
409 |
|
p.execute(new CheckedRunnable() { |
410 |
|
public void realRun() throws InterruptedException { |
414 |
|
}}); |
415 |
|
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
416 |
|
assertEquals(1, p.getTaskCount()); |
417 |
– |
} finally { |
417 |
|
done.countDown(); |
419 |
– |
joinPool(p); |
418 |
|
} |
419 |
|
} |
420 |
|
|