首页 > 编程语言 > 详细

java计时器

时间:2015-11-16 12:41:59      阅读:257      评论:0      收藏:0      [点我收藏+]
import java.util.Timer;
import java.util.TimerTask;
 

public class Timex {
 
  Timer timer;
     public Timex(int seconds) {
         timer = new Timer();
         timer.schedule(new RemindTask(), 0,1000);
     }
     class RemindTask extends TimerTask {
         public void run() {
             System.out.println("你好");
             //timer.cancel(); //Terminate the timer thread
         }
     }
     public static void main(String args[]) {
         //System.out.println("About to schedule task.");
         new Timex(1);
         //System.out.println("Task scheduled.");
     }

}

java计时器

原文:http://my.oschina.net/icngor/blog/530770

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