首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

线程杂么间断不了呢。

2012-08-27 
线程杂么中断不了呢。。。我启动一个线程,然后向中断它,但是中断不了,一直运行。求解。Java codepublic class T

线程杂么中断不了呢。。。
我启动一个线程,然后向中断它,但是中断不了,一直运行。求解。

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


[解决办法]
恭喜楼主解决问题

热点排行