--- jsr166/src/test/tck/JSR166TestCase.java 2015/10/04 18:40:57 1.164 +++ jsr166/src/test/tck/JSR166TestCase.java 2015/10/05 21:39:39 1.166 @@ -201,6 +201,8 @@ public class JSR166TestCase extends Test ("Looks like we're stuck running test: " + lastTestCase); dumpTestThreads(); + // one stack dump is probably enough; more would be spam + break; } lastTestCase = currentTestCase; }}}; @@ -774,10 +776,43 @@ public class JSR166TestCase extends Test public void close() { joinPool(pool); } } + /** + * An extension of PoolCleaner that has an action to release the pool. + */ + class PoolCleanerWithReleaser extends PoolCleaner { + private final Runnable releaser; + public PoolCleanerWithReleaser(ExecutorService pool, Runnable releaser) { + super(pool); + this.releaser = releaser; + } + public void close() { + try { + releaser.run(); + } finally { + super.close(); + } + } + } + PoolCleaner cleaner(ExecutorService pool) { return new PoolCleaner(pool); } + PoolCleaner cleaner(ExecutorService pool, Runnable releaser) { + return new PoolCleanerWithReleaser(pool, releaser); + } + + PoolCleaner cleaner(ExecutorService pool, CountDownLatch latch) { + return new PoolCleanerWithReleaser(pool, releaser(latch)); + } + + Runnable releaser(final CountDownLatch latch) { + return new Runnable() { public void run() { + do { latch.countDown(); } + while (latch.getCount() > 0); + }}; + } + /** * Waits out termination of a thread pool or fails doing so. */