java96-线程的睡眠


//线程的睡眠
public class test31 {
    public static void main(String[] args){
        Xc43 xc43=new Xc43();
        Thread ccc=new Thread(xc43);
        ccc.start();
 
    }
}
class Xc43 implements Runnable {
    public void run(){
        for (int i=0;i<10;i++){
            System.out.println(Thread.currentThread().getName()+""+i);
            try{
                Thread.sleep(1000);
            }catch(Exception e){
 
            }
        }
    }
}
运行结果会发现间断输出

 

posted @ 2022-06-25 15:26  前端导师歌谣  阅读(25)  评论(0)    收藏  举报