我可以看到在调用interrupt()方法时使用了阻塞程序。 我发现AbstractInterruptibleChannel.wake()和AbstractInterruptibleChannel.end()方法隐式调用了blockOn()。
但拦截器使用的是什么? “拦截器”是什么意思?我在字典中搜索后无法确定要选择什么。 为什么我们使用此方法名称:“blockedOn()”?
/* The object in which this thread is blocked in an interruptible I/O
* operation, if any. The blocker's interrupt method should be invoked
* after setting this thread's interrupt status.
*/
private volatile Interruptible blocker;
void blockedOn(Interruptible b) {
synchronized (blockerLock) {
blocker = b;
}
}
public void interrupt() {
if (this != Thread.currentThread())
checkAccess();
synchronized (blockerLock) {
Interruptible b = blocker;
if (b != null) {
interrupt0(); // Just to set the interrupt flag
b.interrupt(this);
return;
}
}
interrupt0();
}