什么是石英默认线程数

What is the quartz default thread count

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

但是它没有找到这意味着什么。这是否意味着只有一个线程或有其他线程'number'?

我正在玩 quartz-scheduler v2.2。

这取决于..

如果你使用 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");
}

尝试使用默认值 org.quartz.threadPool.threadCount=-1

开始 Quartz

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

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

来自jdoc

org.quartz.threadPool.threadCount

Can be any positive integer...