Returns a new CompletionStage with the same result or exception as this stage, that executes the given action using the supplied Executor when this stage completes.
When this stage is complete, the given action is invoked with the
result (or null if none) and the exception (or null
if none) of this stage as arguments. The returned stage is completed
when the action returns.
Unlike method handleAsync,
this method is not designed to translate completion outcomes,
so the supplied action should not throw an exception. However,
if it does, the following rules apply: If this stage completed
normally but the supplied action throws an exception, then the
returned stage completes exceptionally with the supplied
action's exception. Or, if this stage completed exceptionally
and the supplied action throws an exception, then the returned
stage completes exceptionally with this stage's exception.
action | the action to perform | |
executor | the executor to use for asynchronous execution |
Diagram: Future