I'm looking JAVA API docs for CompletableFuture, where I've come across with this particular line,
Actions supplied for dependent completions of non-async methods may be performed by the thread that completes the current CompletableFuture, or by any other caller of a completion method.
Refer link description (https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html)
I have confusion for this specific phrase: "or by any other caller of a completion method"
Q1) What does this actually mean? Due to this, I doubt that whenComplete will execute the same thread or there can be chances to be in the different thread?
I've used CompletableFuture with its supplyAsync()/runAsync() and whenComplete() methods.()
CompletableFuture.supplyAsync(
() -> {DO_SOMETHING}, myExecutor
).whenComplete((result, exception) -> {DO_SOMETHING});
For supplyAsync()/runAsync(), I've used the Executor service. After that, the result of that method (supplyAsync/runAsync) will dive into whenComplete() method.
So the question is: Q2) whenComplete will ALWAYS use the same thread which is used by supplyAsync/runAsync after immediate?
(If whenComplete() method execute in the same thread which is initiated from my Executor at the time of supplyAsync()/runAsync() method.)