我正在查看CompletableFuture中的运算符。thenCombine,但是当我尝试组合两个以上的CompletableFuture对象时,我遇到了一些问题。
示例:
CompletableFuture<List<String>> completableFuture =
CompletableFuture.supplyAsync(() -> fetch.andThen(log).apply(url1))
.thenCombine(CompletableFuture.supplyAsync(() -> fetch.andThen(log).apply(url2)),
//.thenCombine(CompletableFuture.supplyAsync(() -> fetch.andThen(log).apply(url3)),
(s1, s2) -> List.of(s1,s2));
//(s1, s2, s3) -> List.of(s1, s2, s3));
当我尝试添加第三个CompletableFuture时,我在IntelliJ中收到错误。
是否有反馈?
非常感谢
胡安·安东尼奥
您可以这样操作: