"Org.quartz.core related class Diagram"
You can see that the core class is Quartzscheduler
"Quartzscheduler Constructor"
PublicQuartzscheduler (quartzschedulerresources Resources,LongIdlewaittime, @DeprecatedLongdbretryinterval)throwsschedulerexception { This. resources =resources; if(Resources.getjobstore ()instanceofJoblistener) {Addinternaljoblistener (Joblistener) Resources.getjobstore ()); } this.schedthread = new Quartzschedulerthread (this, resources); Threadexecutor schedthreadexecutor = Resources.getthreadexecutor (); Schedthreadexecutor.execute (This.schedthread); if(Idlewaittime > 0) { This. Schedthread.setidlewaittime (Idlewaittime); } jobmgr=NewExecutingjobsmanager (); Addinternaljoblistener (jobmgr); Errlogger=NewErrorlogger (); Addinternalschedulerlistener (Errlogger); Signaler=NewSchedulersignalerimpl ( This, This. Schedthread); if(Shouldrunupdatecheck ()) Updatetimer=Scheduleupdatecheck (); ElseUpdatetimer=NULL; GetLog (). info ("Quartz Scheduler v." + getversion () + "created.");}
This creates a quartzschedulerthread and runs in Threadexecutor (the default defaultthreadexecutor). Threadexecutor here is not our concern, continue to see the quartzschedulerthread of the Run method.
"Quartzschedulerthread#run ()"
The Run method is long and the effect is to find out which job to run and then execute it in the thread pool according to trigger. Here is the code snippet for the Run method:
Jobrunshell Shell =NULL;Try{Shell=qsrsrcs.getjobrunshellfactory (). Createjobrunshell (Bndle); Shell.initialize (QS);} Catch(schedulerexception se) {qsrsrcs.getjobstore (). Triggeredjobcomplete (Triggers.get (i), Bndle.getjobdetail (), COMPLETEDEXECUTIONINSTRUCTION.SET_ALL_JOB_TRIGGERS_ERROR); Continue;}if(Qsrsrcs.getthreadpool (). Runinthread (Shell)==false) { //This case should never happen, as it is indicative of the//Scheduler being shutdown or a bug in the thread pool or//a thread pool being used Concurrently-which the docs//say do ...GetLog (). Error ("Threadpool.runinthread () return false!"); Qsrsrcs.getjobstore (). Triggeredjobcomplete (Triggers.get (i), Bndle.getjobdetail (), Completedexecutioninstruction.set_all_job_triggers_error);}
The threadpool here must implement the Org.quartz.spi.ThreadPool interface.
"ThreadPool Implementation Class"
The default implementation class for ThreadPool is Org.quartz.simpl.SimpleThreadPool.
String Tpclass = Cfg.getstringproperty (Prop_thread_pool_class, Simplethreadpool. Class. GetName ());
(from Org.quartz.impl.stdschedulerfactory#instantiate ())
This thread pool is very simple and has no blockingqueue:
Private New Linkedlist<workerthread>();//Simplethreadpool member privatenew linkedlist< Workerthread> (); Simplethreadpool Members
If integrated with spring, Using Org.springframework.scheduling.quartz.SchedulerFactoryBean and configuring the Taskexecutor (Implementation class for Java.util.concurrent.Executor), the ORG.S Pringframework.scheduling.quartz.LocalTaskExecutorThreadPool.
if (thisnull) { mergedprops.setproperty (Stdschedulerfactory.prop_thread_pool_class, Localtaskexecutorthreadpool. class . GetName ());}
(from Org.springframework.scheduling.quartz.schedulerfactorybean#initschedulerfactory)
You can also customize the implementation class and configure the Org.quartz.threadPool.class parameter for quartzproperties.
Thread pool parsing for quartz