工作者线程配置

##使用线程池
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)来负责触发调度的,

quartz线程模型(一)



quartz线程模型(一)


相关文章:

  • 2021-07-06
  • 2021-05-16
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
猜你喜欢
  • 2021-10-15
  • 2021-05-22
  • 2022-12-23
  • 2021-10-31
  • 2021-04-10
相关资源
相似解决方案