Search code examples
javaquartz-scheduler

What is the quartz default thread count


I am new to Quartz. I did manage to figure out that default value for Scheduler configuration is org.quartz.threadPool.threadCount=-1.

But it did not find anywhere what this implies. Does this mean that there will be only one thread or has it some other 'number'?

I am playing with quartz-scheduler v2.2.


Solution

  • It depends..

    If you use Spring Framework then you can see that the real default is defined in SchedulerFactoryBean:

    public static final int DEFAULT_THREAD_COUNT = 10;
    

    In case of using bare Quartz and and not passing any property, it will use its default configuration, which you can find it in org.quartz.properties:quartz jar. It's called quartz.properties (here's link) and contains:

    # Default Properties file for use by StdSchedulerFactory
    # to create a Quartz Scheduler Instance, if a different
    # properties file is not explicitly specified.
    #
    
    org.quartz.scheduler.instanceName: DefaultQuartzScheduler
    org.quartz.scheduler.rmi.export: false
    org.quartz.scheduler.rmi.proxy: false
    org.quartz.scheduler.wrapJobExecutionInUserTransaction: false
    
    org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
    org.quartz.threadPool.threadCount: 10
    org.quartz.threadPool.threadPriority: 5
    org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true
    
    org.quartz.jobStore.misfireThreshold: 60000
    
    org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore
    

    So, it's 10 in the most cases.

    On the other hand, if you just wanted to create SimpleThreadPool without specyfying thread-pool size, it will throw exception from initialize method as (here's link):

    if (count <= 0) {
        throw new SchedulerConfigException(
                "Thread count must be > 0");
    }