1
CompletableFuture<Object> cf = new CompletableFuture<>();
cf.whenComplete((t, throwable) -> {
System.out.println(Thread.currentThread().toString());
});
cf.complete(new Object());
这将运行whenComplete的BiConsumer
在线程中调用cf.complete)回调(如何欺骗CompletableFuture.complete()在其他线程中运行dependents/stages?
我怎样才能在当前线程(commonPool()
?)无法运行此whenComplete /其他lambda表达式,而不是从调用cf.complete()
另一个线程?