CompletableFuture.allOf 意思
CompletableFuture.allOf meaning
我理解的好吗,我用的时候
CompletableFuture.allOf("array of CompletableFuture")
.runAsync(()-> { "piece of code" });
首先我必须等到 CF 数组全部完成,然后 Runnable“代码段”完成?
CompletableFuture.allOf 静态方法允许等待作为 var-arg 提供的所有 Future 的完成。
例如
CompletableFuture<String> future1
= CompletableFuture.supplyAsync(() -> "Hello");
CompletableFuture<String> future2
= CompletableFuture.supplyAsync(() -> "Beautiful");
CompletableFuture<String> future3
= CompletableFuture.supplyAsync(() -> "World");
CompletableFuture<Void> combinedFuture
= CompletableFuture.allOf(future1, future2, future3);
也就是文档中显式:
Returns a new CompletableFuture that is completed when all of the given CompletableFutures complet
我理解的好吗,我用的时候
CompletableFuture.allOf("array of CompletableFuture")
.runAsync(()-> { "piece of code" });
首先我必须等到 CF 数组全部完成,然后 Runnable“代码段”完成?
CompletableFuture.allOf 静态方法允许等待作为 var-arg 提供的所有 Future 的完成。
例如
CompletableFuture<String> future1
= CompletableFuture.supplyAsync(() -> "Hello");
CompletableFuture<String> future2
= CompletableFuture.supplyAsync(() -> "Beautiful");
CompletableFuture<String> future3
= CompletableFuture.supplyAsync(() -> "World");
CompletableFuture<Void> combinedFuture
= CompletableFuture.allOf(future1, future2, future3);
也就是文档中显式:
Returns a new CompletableFuture that is completed when all of the given CompletableFutures complet