小编lim*_*756的帖子

为什么CompletableFuture allOf方法进行二进制搜索?

我想知道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)

java concurrency completable-future

8
推荐指数
1
解决办法
131
查看次数

标签 统计

completable-future ×1

concurrency ×1

java ×1