743 |
|
} |
744 |
|
|
745 |
|
/** |
746 |
+ |
* Allows use of try-with-resources with per-test thread pools. |
747 |
+ |
*/ |
748 |
+ |
static class PoolCloser<T extends ExecutorService> |
749 |
+ |
implements AutoCloseable { |
750 |
+ |
public final T pool; |
751 |
+ |
public PoolCloser(T pool) { this.pool = pool; } |
752 |
+ |
public void close() { joinPool(pool); } |
753 |
+ |
} |
754 |
+ |
|
755 |
+ |
/** |
756 |
|
* Waits out termination of a thread pool or fails doing so. |
757 |
|
*/ |
758 |
< |
void joinPool(ExecutorService pool) { |
758 |
> |
static void joinPool(ExecutorService pool) { |
759 |
|
try { |
760 |
|
pool.shutdown(); |
761 |
|
if (!pool.awaitTermination(2 * LONG_DELAY_MS, MILLISECONDS)) |