Difference Between Cron trigger and Simple trigger in Quartz Scheduler

送分小仙女□ 提交于 2019-12-05 22:07:12

The differences between the two are merely how you wish to schedule the execution of your jobs. There are no other differences in terms of best practices or thread safety.

SimpleTrigger is useful for jobs that you want to execute exactly once at a specific time, optionally followed by repeated execution at a specific interval.

CronTrigger is much different in that it is for jobs that are inherently recurring on some calendar based schedule. So with CronTrigger you can schedule a job that runs every Sunday at 1AM.

The CronTrigger and SimpleTrigger tutorials contain some more detailed explanations and examples.

The difference comes when you wish interval based schedule.

Cron: if you put ‘0/15’ in the Minutes field, it means ‘every 15th minute of the hour, starting at minute zero’. If you used ‘3/20’ in the Minutes field, it would mean ‘every 20th minute of the hour, starting at minute three’ - or in other words it is the same as specifying ‘3,23,43’ in the Minutes field. Note the subtlety that “/35” does *not mean “every 35 minutes” - it mean “every 35th minute of the hour, starting at minute zero” - or in other words the same as specifying ‘0,35’.

Simple Trigger: if you want the trigger to fire at exactly 11:23:54 AM on January 13, 2015, or if you want it to fire at that time, and then fire five more times, every ten seconds.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!