区别
Executor在于负责运行代码的。每个运算符
CompletableFuture通常具有3个版本。
thenApply(fn)
-fn
在CompleteableFuture
调用它的线程定义的线程上运行,因此您通常不知道在哪里执行该线程。如果结果已经可用,它可能会立即执行。thenApplyAsync(fn)
-fn
无论环境如何,都在环境定义的执行程序上运行。为此CompletableFuture
通常ForkJoinPool.commonPool()
。thenApplyAsync(fn,exec)
-运行fn
上exec
。
最后,结果是相同的,但是调度行为取决于方法的选择。



