How to interrupt underlying execution of CompletableFuture

前端 未结 4 1610
自闭症患者
自闭症患者 2020-12-29 05:04

I know that CompletableFuture design does not control its execution with interruptions, but I suppose some of you might have this problem. CompletableFutu

4条回答
  •  温柔的废话
    2020-12-29 05:28

    If you use

    cf.get();
    

    instead of

    cf.join();
    

    The thread waiting on the completion can be interrupted. This bit me in the a**, so I'm just putting it out there. You'd then need to propagate this interruption further / use cf.cancel(...) to really finish the execution.

提交回复
热议问题