I am new to Completable Futures and trying to understand on which thread a callback registered on CompletableFuture constructed using the the Constructor (new CompletableFuture())
For example:
CompletableFuture<String> future =
CompletableFuture.supplyAsync(() -> {
//...
}, pool);
CompletableFuture<Integer> intFuture =
future.thenApply(s -> s.length());
Transformation in thenApply() is registered and it will be executed immediately after task completion in the same thread as the task.
CompletableFuture<String> future = new CompletableFuture();
CompletableFuture<Integer> intFuture =
future.thenApply(s -> s.length());
future.complete("hello");
Transformation in thenApply() is registered and on which thread will it be executed once the task is completed using future.complete("hello")? Will it be executed on the main thread or will it be executed on ForkJoinPool.commonPool()?