[concurrency-interest] CompletableStage.whenComplete(): Completes the stage after calling the BiConsumer

Alex Otenko oleksandr.otenko at gmail.com
Thu Nov 7 16:53:45 EST 2019


It may be better to say "the action return happens before completion". I
would expect this to be the case - that is, no additional efforts
are needed to make the effects of the action to be visible to any
subsequent handler.

Alex

On Thu, 7 Nov 2019, 21:43 Martin Buchholz via Concurrency-interest, <
concurrency-interest at cs.oswego.edu> wrote:

>
> https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/util/concurrent/CompletionStage.html#whenComplete(java.util.function.BiConsumer)
>
> On Thu, Nov 7, 2019 at 10:49 AM Nathan and Ila Reynolds via
> Concurrency-interest <concurrency-interest at cs.oswego.edu> wrote:
>
>> For CompletableStage.whenComplete(), the Javadoc says "The returned
>> stage is completed when the action returns."  What is the reasoning for
>> completing the future after action returns?
>
>
> The result of the returned stage depends on whether the action failed or
> not.
>
>
>> How do I run action after
>> the future completes?
>>
>
> Why can't you just attach a completion action to either the stage returned
> by whenComplete or its source?
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20191107/8370210d/attachment.html>


More information about the Concurrency-interest mailing list