java 什么是quartz默认线程数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35723948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the quartz default thread count
提问by Jef
I am new to Quartz
. I did manage to figure out that default value for Scheduler configuration is org.quartz.threadPool.threadCount=-1
.
我是新手Quartz
。我确实设法找出调度程序配置的默认值是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.
我在玩quartz-scheduler v2.2。
回答by Maciej Dobrowolski
It depends..
这取决于..
If you use Spring Framework
then you can see that the real default is defined in SchedulerFactoryBean:
如果你使用,Spring Framework
那么你可以看到真正的默认值是在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:
如果使用裸Quartz
和不传递任何属性,它将使用其默认配置,您可以在org.quartz.properties:quartz
jar 中找到它。它被称为quartz.properties
(这里是链接)并包含:
# 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 10in the most cases.
因此,在大多数情况下为10。
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):
另一方面,如果您只是想在SimpleThreadPool
不指定线程池大小的情况下创建,它将从initialize
方法中抛出异常(这里是链接):
if (count <= 0) {
throw new SchedulerConfigException(
"Thread count must be > 0");
}
回答by Eugene Kirin
Try to start Quartz
with default value org.quartz.threadPool.threadCount=-1
尝试从Quartz
默认值开始org.quartz.threadPool.threadCount=-1
It doesn't start. You got org.quartz.SchedulerConfigException: Thread count must be > 0
它没有开始。你得到了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 .
默认-1
值强制您将值配置为大于org.quartz.threadPool.threadCount
0 。
From jdoc
来自jdoc
org.quartz.threadPool.threadCount
Can be any positive integer...
org.quartz.threadPool.threadCount
可以是任何正整数...