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");
        }    
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-09-01
  • 2021-10-15
  • 2021-07-01
  • 2021-09-14
  • 2022-12-23
  • 2021-06-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
  • 2021-10-13
  • 2021-11-19
相关资源
相似解决方案