public class ceshi extends Thread{?public void run(){? ?while(!this.isInterrupted()){ ? System.out.println("線程正在執(zhí)行中"); ? long time=System.currentTimeMillis(); ?while((System.currentTimeMillis()-time)<1000){ ??}? ?}?}?public static void main(String[] args) throws InterruptedException { ceshi xu=new ceshi(); System.out.println("線程開始啟動(dòng)1");//main是主線程 xu.start();? Thread.sleep(3000);? System.out.println("線程正在停止中");? ? xu.interrupted();? ? Thread.sleep(3000);? ? System.out.println("線程已經(jīng)終止");?}}為什么停止不了!??!
interruped(線程的中斷)
woshi123w
2016-07-02 23:38:18