ScheduledExecutorService 定时任务,scheduleAtFixedRate和scheduleWithFixedDelay区别
2017-10-01 00:34
447 查看
比Timer用着方便,用过很多次,经常被用
scheduleWithFixedDelay,每一次以固定的延迟时间开始调度task
scheduleAtFixedRate,每一次以固定的频率开始调度task
scheduleWithFixedDelay,每一次以固定的延迟时间开始调度task
参数 1 command the task to execute 2 initialDelay the time to delay first execution 3 delay the delay between the termination of one execution and the commencement of the next 4 unit the time unit of the initialDelay and delay parameters 解释 第一次调度开始时间点=当前时间+initialDelay 下一次调度开始时间点=上一次task完成时间点+delay
scheduleAtFixedRate,每一次以固定的频率开始调度task
这是参数 1 command the task to execute 2 initialDelay the time to delay first execution 3 period the period between successive executions 4 unit the time unit of the initialDelay and period parameters 解释 第一次调度开始时间点=当前时间+initialDelay 第二次调度开始时间点=initialDelay + perid 第n次调度开始时间点=initialDelay + n *perid 比如: 现在是12:00启动服务 设定initialDelay=1;period=2;unit=小时 第一次:12:00 + 1 =13:00 第二次:12:00 + 1 +2 =15:00 第三次次:12:00 +1 + 2 + 2 =17:00 ...
相关文章推荐
- ScheduledExecutorService定时周期执行指定的任务 ,关于scheduleAtFixedRate 和 scheduleWithFixedDelay使用区别
- ScheduledExecutorService的scheduleAtFixedRate和scheduleWithFixedDelay方法的区别
- Android四大组件之service(二)——用service、scheduleAtFixedRate写一个后台定时执行任务
- ScheduledExecutorService中scheduleAtFixedRate方法同步
- ScheduledExecutorService 的 scheduleAtFixedRate 和 scheduleWithFixedDelay 两个方法的区别
- ScheduledExecutorService中scheduleAtFixedRate方法的同步
- ScheduledExecutorService中scheduleAtFixedRate方法的同步
- Java并发之ScheduledExecutorService(schedule、scheduleAtFixedRate、scheduleWithFixedDelay)
- 如何从Runnable内部跳出ScheduledExecutorService.scheduleAtFixedRate
- ScheduledExecutorService中scheduleAtFixedRate方法的同步
- ScheduledExecutorService中scheduleAtFixedRate与scheduleWithFixedDelay的区别
- 定时任务解决方案1_JDK自带的ScheduledExecutorService
- java定时任务接口ScheduledExecutorService
- ScheduledExecutorService定时任务的使用
- ScheduledExecutorService定时周期执行指定的任务
- ScheduledExecutorService类 scheduleWithFixedDelay() 和 scheduleFixedRate() 区别
- ScheduledExecutorService定时周期执行指定的任务
- java定时任务接口ScheduledExecutorService
- ScheduledExecutorService定时周期运行指定的任务
- java定时任务接口ScheduledExecutorService