schedule() 和 scheduleAtFixedRate() 的区别--转载
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()方法更注重保持执行频率的稳定。
原文地址:http://blog.163.com/nice_2012/blog/static/192666148201231635332934/
转载于:https://www.cnblogs.com/davidwang456/p/4290732.html
《新程序员》:云原生和全面数字化实践50位技术专家共同创作,文字、视频、音频交互阅读总结
以上是生活随笔为你收集整理的schedule() 和 scheduleAtFixedRate() 的区别--转载的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: web工程中spring+ibatis的
- 下一篇: 深入netty源码解析之一数据结构