252 |
|
new CustomTPE(2, 2, |
253 |
|
LONG_DELAY_MS, MILLISECONDS, |
254 |
|
new ArrayBlockingQueue<Runnable>(10)); |
255 |
– |
final CountDownLatch threadStarted = new CountDownLatch(1); |
256 |
– |
final CountDownLatch done = new CountDownLatch(1); |
255 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
256 |
+ |
final CountDownLatch threadStarted = new CountDownLatch(1); |
257 |
+ |
final CountDownLatch done = new CountDownLatch(1); |
258 |
|
assertEquals(0, p.getActiveCount()); |
259 |
|
p.execute(new CheckedRunnable() { |
260 |
|
public void realRun() throws InterruptedException { |
262 |
|
assertEquals(1, p.getActiveCount()); |
263 |
|
done.await(); |
264 |
|
}}); |
265 |
< |
assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); |
265 |
> |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
266 |
|
assertEquals(1, p.getActiveCount()); |
267 |
|
done.countDown(); |
268 |
|
} |
549 |
|
new CustomTPE(1, 1, |
550 |
|
LONG_DELAY_MS, MILLISECONDS, |
551 |
|
new ArrayBlockingQueue<Runnable>(10)); |
552 |
< |
final CountDownLatch threadStarted = new CountDownLatch(1); |
553 |
< |
final CountDownLatch done = new CountDownLatch(1); |
554 |
< |
try { |
552 |
> |
try (PoolCleaner cleaner = cleaner(p)) { |
553 |
> |
final CountDownLatch threadStarted = new CountDownLatch(1); |
554 |
> |
final CountDownLatch done = new CountDownLatch(1); |
555 |
|
assertEquals(0, p.getTaskCount()); |
556 |
|
p.execute(new CheckedRunnable() { |
557 |
|
public void realRun() throws InterruptedException { |
559 |
|
assertEquals(1, p.getTaskCount()); |
560 |
|
done.await(); |
561 |
|
}}); |
562 |
< |
assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); |
562 |
> |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
563 |
|
assertEquals(1, p.getTaskCount()); |
564 |
– |
} finally { |
564 |
|
done.countDown(); |
566 |
– |
joinPool(p); |
565 |
|
} |
566 |
|
} |
567 |
|
|
595 |
|
threadStarted.countDown(); |
596 |
|
done.await(); |
597 |
|
}}); |
598 |
< |
assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); |
598 |
> |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
599 |
|
assertFalse(p.isTerminating()); |
600 |
|
done.countDown(); |
601 |
|
} finally { |
624 |
|
threadStarted.countDown(); |
625 |
|
done.await(); |
626 |
|
}}); |
627 |
< |
assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); |
627 |
> |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
628 |
|
assertFalse(p.isTerminating()); |
629 |
|
done.countDown(); |
630 |
|
} finally { |
659 |
|
tasks[i] = new FutureTask(task); |
660 |
|
p.execute(tasks[i]); |
661 |
|
} |
662 |
< |
assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); |
662 |
> |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
663 |
|
assertSame(q, p.getQueue()); |
664 |
|
assertFalse(q.contains(tasks[0])); |
665 |
|
assertTrue(q.contains(tasks[tasks.length - 1])); |
691 |
|
}}; |
692 |
|
p.execute(tasks[i]); |
693 |
|
} |
694 |
< |
assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); |
694 |
> |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
695 |
|
assertFalse(p.remove(tasks[0])); |
696 |
|
assertTrue(q.contains(tasks[4])); |
697 |
|
assertTrue(q.contains(tasks[3])); |
730 |
|
tasks[i] = new FutureTask(task); |
731 |
|
p.execute(tasks[i]); |
732 |
|
} |
733 |
< |
assertTrue(threadStarted.await(SMALL_DELAY_MS, MILLISECONDS)); |
733 |
> |
assertTrue(threadStarted.await(MEDIUM_DELAY_MS, MILLISECONDS)); |
734 |
|
assertEquals(tasks.length, p.getTaskCount()); |
735 |
|
assertEquals(tasks.length - 1, q.size()); |
736 |
|
assertEquals(1L, p.getActiveCount()); |