Difference between cron trigger and simple trigger in Quartz Scheduler

I am studying a quartz planner,

What are the differences between a Cron trigger and a simple trigger, other than how they are defined. I don't find any other differences.

which is thread safe or which is called best practice or something like that.

can someone please explain what are the differences between them and in what scenarios we could use them.

+3


source to share


2 answers


The differences between the two are simply how you want to schedule your jobs to run. There are no other differences regarding best practice or thread safety.

SimpleTrigger

useful for tasks that you want to complete exactly once at a specific time, optionally followed by re-execution at a specific interval.



CronTrigger

is very different in that it is designed for tasks that, by their nature, repeat on a calendar schedule. Thus, using CronTrigger

you can schedule a task that runs every Sunday at 1:00 am.

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

+7


source


The difference occurs when you want an 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 20 -th minute of the hour, starting from the third minute ", or, in other words, this is the same as specifying" 3,23,43 in the "Minutes" field. Note the subtlety that "/ 35" does * does not mean "every 35 minutes" - this means "every 35 minutes of the hour, starting from minute zero" - or, in other words, the same as the indication "0.35.



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

+2


source







All Articles