Loom on Scala

Eric Kolotyluk eric at kolotyluk.net
Sun Nov 28 16:56:20 UTC 2021


@Alan Bateman <Alan.Bateman at oracle.com>

Yes, I am being pedantic about ExecutorService(s)... perhaps overly
pedantic...

Thanks for confirming that join() is idempotent. It would be nice to state
that clearly in the documentation.

try {
    structuredExecutor.joinUntil(Instant.now().plusSeconds(10));}catch
(TimeoutException e) {    structuredExecutor.shutdown(); // after this
returns, the join() has completed}

It would also be nice to document the above example to make this clear. I
love documentation with examples, as a picture is worth a thousand words...

Cheers, Eric


On Sun, Nov 28, 2021 at 8:05 AM Alan Bateman <Alan.Bateman at oracle.com>
wrote:

> On 28/11/2021 14:50, Eric Kolotyluk wrote:
>
> @Alan Bateman <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