首页 > 其他 > 详细

每隔10秒钟打印一个“Helloworld”

时间:2017-11-13 20:39:06      阅读:197      评论:0      收藏:0      [点我收藏+]
/**
 * 每隔10秒钟打印一个“Helloworld”
 */
public class Test03 {

    public static void main(String[] args) throws InterruptedException {
        ThreadImp threadImp = new ThreadImp();
        Thread thread1 = new Thread(threadImp);
        thread1.start();
    }
}

class ThreadImp extends Thread {
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("StartThread-"
                    + (i + 1)
                    + ":"
                    + new SimpleDateFormat("yyyy/MM/dd hh:mm:ss:Ms")
                            .format(new Date()));
            System.out.println("hello world");
            try {
                sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

 

每隔10秒钟打印一个“Helloworld”

原文:http://www.cnblogs.com/areyouready/p/7827692.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!