我正在尝试创建CompletableFuture的子类,所有其他方面都运行良好,但是当我使用CompletableFuture.allOf时,它永远不会完成。
“ test2全部处理完毕”从未打印过-如果我将所有TimedCF替换为通用CompletableFuture,它将按预期工作。...
感谢您的帮助!
代码示例:
class TimedCF<T> extends CompletableFuture<T> {
CompletableFuture<T> orig = null;
public TimedCF(CompletableFuture<T> ct) {
this.orig = ct;
}
... all other public methods delegated by intellij auto gen
... all static methods proxy to CompletableFuture
}
TimedCF<String> cf1 = new TimedCF(CompletableFuture.completedFuture("string 1"));
TimedCF<String> cf2 = new TimedCF(CompletableFuture.completedFuture("string 2"));
CompletableFuture.anyOf(cf1, cf2)
.handle( (ignore, ex) -> {
System.out.println("test2 all of handled");
return null;
} );