Reputation: 507
I am exploring on quartz scheduler,
What are the differences between Cron trigger and Simple trigger except for how they are being defined. I dint find any other differences.
like which is thread safe or which is said as best practice or anything like that.
can someone explain what are the differences between them and at what scenarios we could use them
Upvotes: 4
Views: 12951
Reputation: 2451
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.
Upvotes: 2
Reputation: 9497
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.
Upvotes: 13