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源码解析之一数据结构