日期:2014-05-20 浏览次数:20924 次
public class Test2 {
/**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
Thread t = new Thread(new T());
t.start();
Thread.sleep(3000);
t.interrupt();
}
}
class T extends Thread {
@Override
public void run() {
while (true) {
if (this.isInterrupted()) {
System.out.println("被打断了");
break;
}
System.out.println("running");
}
}
}