[External] : Re: A new build and a new structured concurrency API
Eric Kolotyluk
eric at kolotyluk.net
Tue Nov 16 00:58:03 UTC 2021
Okay, that makes more sense and satisfies my suspicions. Thanks...
For now, I can live with it, but this would be valuable insight to add to
the JEP.
Cheers, Eric
On Mon, Nov 15, 2021 at 4:53 PM Ron Pressler <ron.pressler at oracle.com>
wrote:
>
>
> > On 15 Nov 2021, at 23:33, Eric Kolotyluk <eric at kolotyluk.net> wrote:
> >
> > So, what is the rationale behind explicitly requiring 'join' or
> 'joinUntil'? Why can't close() at the end of the try-block implicitly deal
> with that?
> >
> > Cheers, Eric
>
>
> That’s a good question!
> The rational is to deal with a current limitation of AutoCloseable — it
> cannot distinguish between the case where the try block
> terminates normally or exceptionally. This means that the implicit close
> would either have to cancel all tasks and then wait or
> just wait, regardless of whether an exception has been thrown. If we
> choose the former, there can be situations where a piece
> of code would just happen to work because the tasks happened to complete
> before close managed to cancel them, concealing a bug.
> If we chose the latter, an exception in the owner would result in all
> tasks still being waited for, which could also be confusing.
>
> Requiring an explicit join avoids these problems. If the language is
> changed to make AutoCloseable more flexible, this requirement
> might be removed.
>
> — Ron
More information about the loom-dev
mailing list