2
之前,有任何机会,因一时thenApply
/thenAccept
方法被称为新CompletableFuture对象,未来的执行将已经完成,并通过上述方法设置处理程序不会有什么影响? 我并不只是想到了这两种方法,而是接受了CompletableFuture API处理程序的全部〜50个方法。完成CompletableFuture <T>添加回调
CompletableFuture<String> f = CompletableFuture.supplyAsync(() -> toString());
f.thenApply(s -> f); // will be called if "f" completes before this line is invoked?
在两者之间放置一个'Thread.sleep'并将回调中的线程记录到'thenApply'。 –
你的意思是“不会有任何影响”?当然,他们仍然有效果,只是立即,而不是稍后。 – Holger