--- jsr166/src/test/tck/ThreadPoolExecutorTest.java 2015/10/04 02:34:48 1.86 +++ jsr166/src/test/tck/ThreadPoolExecutorTest.java 2015/10/04 02:38:46 1.87 @@ -563,10 +563,10 @@ public class ThreadPoolExecutorTest exte new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, q); - Runnable[] tasks = new Runnable[5]; - final CountDownLatch threadStarted = new CountDownLatch(1); - final CountDownLatch done = new CountDownLatch(1); - try { + try (PoolCleaner cleaner = cleaner(p)) { + Runnable[] tasks = new Runnable[6]; + final CountDownLatch threadStarted = new CountDownLatch(1); + final CountDownLatch done = new CountDownLatch(1); for (int i = 0; i < tasks.length; i++) { tasks[i] = new CheckedRunnable() { public void realRun() throws InterruptedException { @@ -585,9 +585,7 @@ public class ThreadPoolExecutorTest exte assertTrue(q.contains(tasks[3])); assertTrue(p.remove(tasks[3])); assertFalse(q.contains(tasks[3])); - } finally { done.countDown(); - joinPool(p); } } @@ -602,8 +600,8 @@ public class ThreadPoolExecutorTest exte new ThreadPoolExecutor(1, 1, LONG_DELAY_MS, MILLISECONDS, q); - FutureTask[] tasks = new FutureTask[5]; - try { + try (PoolCleaner cleaner = cleaner(p)) { + FutureTask[] tasks = new FutureTask[5]; for (int i = 0; i < tasks.length; i++) { Callable task = new CheckedCallable() { public Boolean realCall() throws InterruptedException { @@ -627,9 +625,7 @@ public class ThreadPoolExecutorTest exte p.purge(); // Nothing to do assertEquals(tasks.length - 3, q.size()); assertEquals(tasks.length - 2, p.getTaskCount()); - } finally { done.countDown(); - joinPool(p); } }