I just read the documentation about CompletableFuture::runAsyncand was rather confused by the explanation. Here is what it says:
Returns a new CompletableFutureone that asynchronously completes the task that is executed in this executor after the start of this action.
As I understand it, CompletableFutureit looks like Futureit can "register" some kind of callbacks and call them implicitly after this action is completed.
Given this, consider the following code:
ExecutorService threadsPool;
Runnable r;
//...
CompletableFuture.runAsync(r, threadsPool);
In this code we register Runnablewhich will be executed asynchronously in the given one ThreadPool.
But what does it mean , which asynchronously ends with the task . How can I complete the task ...? It makes no sense to me. CompletableFutureCompletableFuture
source
share