Loom on Scala

Alan Bateman Alan.Bateman at oracle.com
Sun Nov 28 16:05:23 UTC 2021


On 28/11/2021 14:50, Eric Kolotyluk wrote:
> @Alan Bateman <mailto:Alan.Bateman at oracle.com>
> I noticed that StructuredExecutor has a shutdown() while 
> newThreadPerTaskExectutor() has both shutdown() and shutdownNow()...
>
> Also, shutdown() on StructuredExecutor is very different...*/it is 
> much more useful./*

ExecutorService has a different life cycle, we've already been down the 
road of having a structured-ES.

>
> The documentation for shutdown() 
> <https://urldefense.com/v3/__https://download.java.net/java/early_access/loom/docs/api/java.base/java/util/concurrent/StructuredExecutor.html*shutdown()__;Iw!!ACWV5N9M2RV99hQ!ftdLOUqgHeoZoTfZ79E85uf49n-Wjs57GM5XKWHxeyeoVlW17M1nNKP6yvZlRqxNGg$> 
> is not clear to me in that, if shutdown() prepares for join(), in that 
> join() will then return immediately without waiting, do we still need 
> to call join() before close()? For example
> try {
>      structuredExecutor.joinUntil(Instant.now().plusSeconds(10)); }
> catch (TimeoutException e) {structuredExecutor.shutdown(); structuredExecutor.join(); }
> Why do I still need to call join() a second time?
You don't, it would be a no-op as the executor is shutdown.

-Alan


More information about the loom-dev mailing list