# interrupt

作用:打断 sleep,wait,join 的线程

# 情况一

# 情况二 打断正常线程

@Slf4j
public class Demo {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            while (true) {
                // 如果这里不判断的化,外部调用了interrupt,也不会停止
                // interrupt 只是一个打断标记
                if (Thread.currentThread().isInterrupted()) {
                    break;
                }
            }
        }, "t1");

        thread.start();
        TimeUnit.SECONDS.sleep(2);
        thread.interrupt();
    }
}