/** @return  <code>true</code> if this thread has been interrupted;
*          <code>false</code> otherwise.
*    默认返回false, 处于未中断状态;如果被中断返回false
*/
public boolean isInterrupted() {
    return isInterrupted(false);
}
// 设置中断状态,再次调用isInterrupted()会返回true
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();
}
进入Hotspot源码jvm.cpp文件中

Thread中的中断方法-LMLPHP

再进入os_linux.cpp

Thread中的中断方法-LMLPHP

然后进入osThread.hpp

Thread中的中断方法-LMLPHP

进入jvm.cpp中

Thread中的中断方法-LMLPHP

os_linux.cpp,先复位,再进入jvm.cpp中抛出异常

Thread中的中断方法-LMLPHP

/* @return  <code>true</code> if the current thread has been interrupted;
 *          <code>false</code> otherwise.
 * @see #isInterrupted()
 * @revised 6.0
 */
public static boolean interrupted() {
    return currentThread().isInterrupted(true);
}
进入os_linux.cpp

Thread中的中断方法-LMLPHP

03-08 07:07