线程被中断时可以休眠吗?
Can thread sleep when it got interrupted?
在 waitComplete
中,我有一个等待锁的同步块。我担心的是预定中断会在等待之前触发。中断标志打开时是否允许主线程等待?
try {
executor.schedule(currentThread::interrupt,100, TimeUnit.MILLISECONDS);
completor.waitComplete();
fail();
} catch (InterruptedException e) {}
Throws:
InterruptedException - if any thread interrupted the current thread before or while the current thread was waiting for a notification.
(强调我的)
在 waitComplete
中,我有一个等待锁的同步块。我担心的是预定中断会在等待之前触发。中断标志打开时是否允许主线程等待?
try {
executor.schedule(currentThread::interrupt,100, TimeUnit.MILLISECONDS);
completor.waitComplete();
fail();
} catch (InterruptedException e) {}
Throws: InterruptedException - if any thread interrupted the current thread before or while the current thread was waiting for a notification.
(强调我的)