quartz线程模型(一)

工作者线程配置

##使用线程池
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
## 线程数量
org.quartz.threadPool.threadCount: 15
## 设置工作者线程的优先级
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread:  true


下面看一下SimpleThreadPool的源码 , 这是一个固定大小的线程池。

public  class  SimpleThreadPool  implements  ThreadPool {
 
     /*
      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      *
      * Data members.
      *
      * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      */
     // 初始化线程数,对应配置文件里面的threadCount
     private  int  count = - 1 ;
     // 线程优先级
     private  int  prio = Thread.NORM_PRIORITY;
     // 线程是否停止
     private  boolean  isShutdown =  false ;
     //
     private  boolean  handoffPending =  false ;
 
     private  boolean  inheritLoader =  false ;
 
     private  boolean  inheritGroup =  true ;
 
     private  boolean  makeThreadsDaemons =  false ;
 
     private  ThreadGroup threadGroup;
 
     private  final  Object nextRunnableLock =  new  Object();
     // 工作线程
     private  List<WorkerThread> workers;
     // 可用线程
     private  LinkedList<WorkerThread> availWorkers =  new  LinkedList<WorkerThread>();
     // 忙碌线程
     private  LinkedList<WorkerThread> busyWorkers =  new  LinkedList<WorkerThread>();
 
     private  String threadNamePrefix;
 
     private  final  Logger log = LoggerFactory.getLogger(getClass());
     
     private  String schedulerInstanceName;
该线程池主要是负责任务的执行,任务的触发是由一个主线程(QuartzSchedulerThread)来负责触发调度的,





猜你喜欢

转载自blog.csdn.net/u012394095/article/details/80424293