I want to execute CompletableFutureonce when it finishes CompletableFuture, regardless of whether the first of them finishes exclusively (it .thenCompose()is executed only when completion is complete).
For instance:
CompletableFuture.supplyAsync(() -> 1L)
.whenComplete((v, e) -> CompletableFuture.runAsync(() -> {
try {
Thread.sleep(1000);
System.out.println("HERE");
} catch(InterruptedException exc) {
return;
}
}))
.whenComplete((v, e) -> System.out.println("ALL DONE"));
Will print
ALL DONE
HERE
and I would like him to be
HERE
ALL DONE
preferably without inserting the second whenComplete()inside the first.
Please note that here I am not interested in the returned result / exception.
source
share