Java延时器

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");
        }    
    }
}
原文地址:https://www.cnblogs.com/lifusen/p/8289135.html