什么是石英默认线程数

时间:2016-03-01 13:14:48

标签: java quartz-scheduler

我是Quartz的新手。我确实设法确定调度程序配置的默认值是org.quartz.threadPool.threadCount=-1

但它并没有发现这意味着什么。这是否意味着只有一个线程或其他一些'数字'?

我正在使用quartz-scheduler v2.2。

2 个答案:

答案 0 :(得分:9)

取决于..

如果您使用Spring Framework,则可以看到SchedulerFactoryBean中定义了真正的默认值:

public static final int DEFAULT_THREAD_COUNT = 10;

如果使用裸Quartz并且没有传递任何属性,它将使用其默认配置,您可以在org.quartz.properties:quartz jar中找到它。它被称为quartz.properties (here's link)并包含:

# 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

因此,大多数情况下 10

另一方面,如果您只想在不指定线程池大小的情况下创建SimpleThreadPool,它将从initialize方法抛出异常(here's link):

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

答案 1 :(得分:1)

尝试使用默认值Quartz

启动org.quartz.threadPool.threadCount=-1

它没有开始。你有org.quartz.SchedulerConfigException: Thread count must be > 0

默认-1值会强制您将org.quartz.threadPool.threadCount配置为超过0的值。

来自jdoc

  

<强> org.quartz.threadPool.threadCount

     

可以是任何正整数......