package com.company.bingfa;
class MyThread13 extends Thread{
private int n;
@Override
public void run() {
n = 0;
System.out.println("线程开始");
while(true){
if(isInterrupted()){
System.out.println("被中断了");
break;
}
n++;
if(n%100 == 0){
System.out.println("n="+n);
}
}
System.out.println("线程结束");
}
}
public class MyInterrupt {
public static void main(String[] args) throws InterruptedException {
MyThread13 t = new MyThread13();
t.start();
Thread.sleep(3000);
t.interrupt();
}
}