Concurrency and Exceptions
Alan Bateman
Alan.Bateman at oracle.com
Wed Dec 1 08:43:36 UTC 2021
On 30/11/2021 21:02, Paul Bjorkstrand wrote:
>
> :
>
> Would you say that the intent of CompletionHandler is to negate, to
> some degree, the need to individually call
> Future.[result|exception]Now() (outside the handler, that is)? That is
> what it sounds like to me, and it makes a CompletionHandler's purpose
> a lot more useful than just "short circuit other tasks on the first
> success/failure".
>
The javadoc [1] has been expanded to try to make it clearer that the
handler can implement policy, collect results and/or exception, and
define an API to make the outcome available for use after the join
method has been invoked. So depending on the handler, it maybe that the
code after join doesn't need to invoke Future methods, or in the example
using ShutdownOnFailure, it can invoke resultNow on all Future objects
because it is known that all tasks have completed successfully.
-Alan
[1]
https://download.java.net/java/early_access/loom/docs/api/java.base/java/util/concurrent/StructuredExecutor.CompletionHandler.html
More information about the loom-dev
mailing list