利用线程每十秒打印一句话

public class Test implements Runnable{

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Test t = new Test();
        Thread tA = new Thread(t);
        tA.start();
    }
    
    @Override
    public void run() {
        // TODO Auto-generated method stub
        int count=0;
        while(++count<10){
            System.out.println("123123123");
            try {
                Thread.sleep(100);
            } catch (Exception e) {
                // TODO: handle exception
                e.printStackTrace();
            }
        }
    }
}

 

posted @ 2019-04-03 18:41  小小超plus  阅读(281)  评论(0编辑  收藏  举报