================================= 像这种问题,直接看源代码就可以了。 public void interrupt() { if (this != Thread.currentThread()) checkAccess(); synchronized (blockerLock) { Interruptible b = blocker; if (b != null) { interrupt0(); b.interrupt(); return; } } interrupt0(); } private native void interrupt0();
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(); } 这是源码,它不是打断线程,而是清除中断线程,让线程回到运行状态,你可以查手册和源码,这样对学习是有好处的
像这种问题,直接看源代码就可以了。
public void interrupt() {
if (this != Thread.currentThread())
checkAccess(); synchronized (blockerLock) {
Interruptible b = blocker;
if (b != null) {
interrupt0();
b.interrupt();
return;
}
}
interrupt0();
} private native void interrupt0();
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();
}
这是源码,它不是打断线程,而是清除中断线程,让线程回到运行状态,你可以查手册和源码,这样对学习是有好处的
这个美女,这个方法是中断线程哟。至于怎么中断的,应该是 private native void interrupt0();