gpt4 book ai didi

java - 线程被中断时可以 hibernate 吗?

转载 作者:行者123 更新时间:2023-12-01 17:52:27 25 4
gpt4 key购买 nike

waitComplete中,我有一个等待锁的同步块(synchronized block)。我担心的是预定的中断会在等待之前触发。当中断标志打开时,是否允许主线程等待?

try {
executor.schedule(currentThread::interrupt,100, TimeUnit.MILLISECONDS);
completor.waitComplete();
fail();
} catch (InterruptedException e) {}

最佳答案

Javadoc :

Throws: InterruptedException - if any thread interrupted the current thread before or while the current thread was waiting for a notification.

(强调我的)

关于java - 线程被中断时可以 hibernate 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48524563/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com