--- jsr166/src/test/tck/JSR166TestCase.java 2015/10/03 23:17:03 1.158 +++ jsr166/src/test/tck/JSR166TestCase.java 2015/10/04 00:59:09 1.160 @@ -770,13 +770,16 @@ public class JSR166TestCase extends Test /** * Allows use of try-with-resources with per-test thread pools. */ - class PoolCloser - implements AutoCloseable { - public final T pool; - public PoolCloser(T pool) { this.pool = pool; } + class PoolCleaner implements AutoCloseable { + private final ExecutorService pool; + public PoolCleaner(ExecutorService pool) { this.pool = pool; } public void close() { joinPool(pool); } } + PoolCleaner cleaner(ExecutorService pool) { + return new PoolCleaner(pool); + } + /** * Waits out termination of a thread pool or fails doing so. */ @@ -809,9 +812,8 @@ public class JSR166TestCase extends Test * necessarily individually slow because they must block. */ void testInParallel(Action ... actions) { - try (PoolCloser poolCloser - = new PoolCloser<>(Executors.newCachedThreadPool())) { - ExecutorService pool = poolCloser.pool; + ExecutorService pool = Executors.newCachedThreadPool(); + try (PoolCleaner cleaner = cleaner(pool)) { ArrayList> futures = new ArrayList<>(actions.length); for (final Action action : actions) futures.add(pool.submit(new CheckedRunnable() {