I have a question about CompletableFuture method:
public <U> CompletableFuture<U> thenApply(Function<? super T, ? extends U> fn)
The thing is the JavaDoc says just this:
Returns a new CompletionStage that, when this stage completes normally, is executed with this stage's result as the argument to the supplied function. See the CompletionStage documentation for rules covering exceptional completion.
What about threading? In which thread is this going to be executed? What if the future is completed by a thread pool?
The policies as specified in the
CompletableFuture
docs could help you understand better:Update: I would also advice on reading this answer by @Mike as an interesting analysis further into the details of the documentation.