On Fri, Jul 3, 2020 at 11:12 PM Alan Bateman <[email protected]> wrote:
> - "service" isn't a great name for the Executor. Also you can make use
> of try-finally, e.g.
> ExecutorService executor = Executors.newFixedThreadPool(1);
> try { ... } finally { executor.shutdown(); }
If you want to do this structured-concurrency-style, you should wait
for all the threads you started to complete (they might block!).
shutdown is not enough - you also want awaitTermination.
We have a PoolCleaner utility in test/jdk/java/util/concurrent/tck/ to
help do this.
try (PoolCleaner cleaner = cleaner(p)) {