今天突然想到這個執行定時任務是需要花時間的,如果設置的間隔小於任務所需的時間會是什么情況?定時任務是單線程還是多線程的?
哈哈 又是從網上找到的資料,萬能的互聯網。
task:scheduled 配置默認是單線程串行的,如下配置可以配置多線程。
<task:scheduler id="scheduler" pool-size="4" /> <task:scheduled-tasks scheduler="scheduler"> <task:scheduled ref="pmTask" method="getMinutePm" cron="0 0/1 * * * ?"/> <task:scheduled ref="outsidePmTask" method="getOutsidePm" cron="0 30/30 * * * ?"/> <task:scheduled ref="pmTask" method="getHourPm" cron="0 0 0/1 * * ? "/> <task:scheduled ref="pmTask" method="getDayPm" cron="0 0 0 1/1 * ? "/> </task:scheduled-tasks>
參考 : http://www.cnblogs.com/youtianhong/p/6027249.html
http://blog.csdn.net/loongshawn/article/details/50663393