小编phi*_*hil的帖子

如何中断CompletableFuture :: join?

我发现,如果没有完成,它CompletableFuture::join似乎是不可中断的:

// CompletableFuture::join implementation from JDK 8 sources
public T join() { 
    Object r;
    return reportJoin((r = result) == null ? waitingGet(false) : r);
}
Run Code Online (Sandbox Code Playgroud)

在上面的实现中,waitingGet(false)将忽略工作的中断标志Thread并继续等待.我想知道我怎么能打断Thread我打电话的地方CompletableFuture::join.

java multithreading interrupt java-8 completable-future

4
推荐指数
1
解决办法
847
查看次数