public class ceshi extends Thread{ public void run(){ while(!this.isInterrupted()){ System.out.println("线程正在执行中"); long time=System.currentTimeMillis(); while((System.currentTimeMillis()-time)<1000){ } } } public static void main(String[] args) throws InterruptedException { ceshi xu=new ceshi(); System.out.println("线程开始启动1");//main是主线程 xu.start(); Thread.sleep(3000); System.out.println("线程正在停止中"); xu.interrupted(); Thread.sleep(3000); System.out.println("线程已经终止"); }}为什么停止不了!!!
添加回答
举报
0/150
提交
取消