当前位置: 代码迷 >> J2SE >> 线程杂么间断不了呢。
  详细解决方案

线程杂么间断不了呢。

热度:7490   发布时间:2013-02-25 00:00:00.0
线程杂么中断不了呢。。。
我启动一个线程,然后向中断它,但是中断不了,一直运行。求解。

Java code
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");        }    }}


------解决方案--------------------------------------------------------
恭喜楼主解决问题
  相关解决方案