I have a specific thread that runs async using CompletableFuture, for example:
foo(...)
.thenAccept(aaa -> {
if (aaa == null) {
break!
}
else {
...
}
})
.thenApply(aaa -> {
...
})
.thenApply(...
So, if mine foo()returns null(in the future), I need to break through very soon, otherwise the thread will continue.
Currently, I have to check in nullfull, in every future block; but it is ugly.
Is this possible with help CompletableFuture?
EDIT
With it, CompletableFutureyou can define the flow of async tasks that run one after another. For example, you can say:
Do A, and when A finishes, do B, and then do C ...
My question is to break this thread and say:
Do A, but if the result is null break; otherwise, B, and then do C ...
, "".