首页 > 其他 > 详细

schedule() 和 scheduleAtFixedRate() 区别

时间:2015-01-08 10:52:35      阅读:269      评论:0      收藏:0      [点我收藏+]

1.  schedule() ,2个参数方法:
在执行任务时,如果指定的计划执行时间scheduledExecutionTime <=
systemCurrentTime,则task会被立即执行。

2.  schedule() ,3个参数方法:
在执行任务时,如果指定的计划执行时间scheduledExecutionTime <=
systemCurrentTime,则task会被立即执行,之后按period参数固定重复执行。

3.  scheduleAtFixedRate() ,3个参数方法:
在执行任务时,如果指定的计划执行时间scheduledExecutionTime<=
systemCurrentTime,则task会首先按执行一次;然后按照执行时间、系统当前时间和period参数计算出过期该执行的次数,计算按照:
(systemCurrentTime-scheduledExecutionTime)/period,再次执行计算出的次数;最后按period参数固定重复执行。

4.  schedule() 和scheduleAtFixedRate()

schedule()方法更注重保持间隔时间的稳定。
scheduleAtFixedRate()方法更注重保持执行频率的稳定。

schedule() 和 scheduleAtFixedRate() 区别

原文:http://www.cnblogs.com/jirglt/p/4210085.html

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