Can more than one thread safely call methods on an instance of Scheduler returned by the StdSchedulerFactory concurrently?
I had this problem so thought I'd look at the source code. Assuming you are using a standard configuration of Quartz (storing jobs and triggers in RAM instead of a persistent JobStore), then it appears that Quartz is thread safe.
Digging into the source, you will finally get to the RamJobStore, which stores all jobs and triggers in memory.
public void storeJobAndTrigger(SchedulingContext ctxt, JobDetail newJob,
Trigger newTrigger) throws JobPersistenceException {
storeJob(ctxt, newJob, false);
storeTrigger(ctxt, newTrigger, false);
}
In each of the storeJob(..) and storeTrigger(..) methods, there are separate synchronized blocks with their own unique objects for storing jobs and triggers in a thread safe manner:
synchronized (jobLock) {
if (!repl) {
// get job group
...
}
}
And synchronizing a trigger:
synchronized (triggerLock) {
...
synchronized (pausedTriggerGroups) {
...
}
}
So in short, it would appear that you can make thread safe calls to an instance of the Scheduler class
This post on the Terracotta website confirms it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With