我想知道allOf方法CompletableFuture是否进行轮询或进入等待状态,直到所有CompletableFutures传递给该方法的执行完成。我在其中查看了该allOf方法的代码,IntelliJ它正在执行某种二进制搜索。
请帮助我找出实际的allOf方法CompletableFuture。
public static CompletableFuture<Void> allOf(CompletableFuture<?>... cfs) {
return andTree(cfs, 0, cfs.length - 1);
}
/** Recursively constructs a tree of completions. */
static CompletableFuture<Void> andTree(CompletableFuture<?>[] cfs, int lo, int hi) {
CompletableFuture<Void> d = new CompletableFuture<Void>();
if (lo > hi) // empty
d.result = NIL;
else {
CompletableFuture<?> a, b;
int mid = (lo + hi) >>> 1;
if ((a = (lo == mid ? …Run Code Online (Sandbox Code Playgroud)