转载自https://www.cnblogs.com/xrq730/p/4856361.html
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();
return;
}
}
interrupt0();
}
1 /* Some private helper methods */
2 private native void setPriority0(int newPriority);
3 private native void stop0(Object o);
4 private native void suspend0();
5 private native void resume0();
6 private native void interrupt0();
分两部分看:
(1)第一部分的第8行注释说得很清楚了,interrupt0()方法的作用是"Just to set the interrupt flag",即方法的作用仅仅是设置中断标识位
(2)第二部分的第6行就是interrupt0()方法的原型,由于方法是被native修饰的,很明显这是一个本地方法,是Java虚拟机实现的