What is the quartz default thread count

本秂侑毒 提交于 2020-01-02 04:12:12

问题


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.


回答1:


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");
}



回答2:


Try to start Quartz with default value org.quartz.threadPool.threadCount=-1

It doesn't start. You got org.quartz.SchedulerConfigException: Thread count must be > 0

The default -1 value force you to config org.quartz.threadPool.threadCount to your value more then 0 .

From jdoc

org.quartz.threadPool.threadCount

Can be any positive integer...



来源:https://stackoverflow.com/questions/35723948/what-is-the-quartz-default-thread-count

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!