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("线程已经终止");
}
}
为什么停止不了!!!
redstonesl
相关分类