首页 > 编程语言 > 详细

建立一个每隔10秒执行的线程

时间:2017-12-03 12:25:39      阅读:484      评论:0      收藏:0      [点我收藏+]
//线程类
public class TestThread extends Thread {
    public void run() {
        while(true){
            try {
                sleep(6*1000);
                                //这里可以写你自己要运行的逻辑代码
                System.out.println("一分钟运行一次");
            catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
             
        }
    }
}
//运行线程类MAIN
public class TestThreadMain {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        TestThread testThread = new TestThread();
        testThread.start();
    }
 
}

建立一个每隔10秒执行的线程

原文:http://www.cnblogs.com/kongxc/p/7965707.html

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