384 |
|
new ThreadPoolExecutor(1, 1, |
385 |
|
LONG_DELAY_MS, MILLISECONDS, |
386 |
|
new ArrayBlockingQueue<Runnable>(10)); |
387 |
< |
final CountDownLatch threadStarted = new CountDownLatch(1); |
388 |
< |
final CountDownLatch done = new CountDownLatch(1); |
389 |
< |
try { |
387 |
> |
try (PoolCleaner cleaner = cleaner(p)) { |
388 |
> |
final CountDownLatch threadStarted = new CountDownLatch(1); |
389 |
> |
final CountDownLatch done = new CountDownLatch(1); |
390 |
|
assertEquals(0, p.getPoolSize()); |
391 |
|
p.execute(new CheckedRunnable() { |
392 |
|
public void realRun() throws InterruptedException { |
394 |
|
assertEquals(1, p.getPoolSize()); |
395 |
|
done.await(); |
396 |
|
}}); |
397 |
< |
assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); |
397 |
> |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
398 |
|
assertEquals(1, p.getPoolSize()); |
399 |
< |
} finally { |
400 |
< |
done.countDown(); |
401 |
< |
joinPool(p); |
399 |
> |
done.countDown(); // release pool |
400 |
|
} |
401 |
|
} |
402 |
|
|