首页 > 编程语言 > 详细

Java延时器

时间:2018-01-15 18:04:35      阅读:215      评论:0      收藏:0      [点我收藏+]
package listener;

import java.util.Timer;
import java.util.TimerTask;

public class Timeer {
    /**
     * schedule(TimerTask task, long delay)的注释:
     * Schedules thespecified task for execution after the specifieddelay。
     * 大意是在延时delay毫秒后执行task。并没有提到重复执行
    * schedule(TimerTask task, long delay, long period)的注释:
     * Schedulesthe specified task for repeated fixed-delay execution, beginningafter the specified delay。
     * 大意是在延时delay毫秒后重复的执行task,周期是period毫秒。
     */
    public static void main(String[] args)
    {
        Timer timer = new Timer();
        timer.schedule(new Timeer().new Timeaa(), 3*1000, 1000*3);
    }
    class Timeaa extends TimerTask{
        public void run() {
            System.out.println("cj");
        }    
    }
}

 

Java延时器

原文:https://www.cnblogs.com/lifusen/p/8289135.html

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