Understanding CompletableFuture::runAsync
Inside CompletableFuture
there is the following code called by runAsync
.
static CompletableFuture<Void> asyncRunStage(Executor e, Runnable f) { if (f == null) throw new NullPointerException(); CompletableFuture<Void> d = new CompletableFuture<Void>(); e.execute(new AsyncRun(d, f)); return d;}
AsyncRun
is the asynchronously executed task that will, after running the Runnable f
, complete the CompletableFuture d
asynchronously. I won't bother with the code here because it's not very informative, and it just performs the completion of d
by calling its postComplete()
method (the package-private one).