Quartz 调度器最大线程数属性 [英] Quartz scheduler max thread count property
问题描述
我有以下情况:
计划运行 8 个任务,org.quartz.threadPool.threadCount
设置为 5.
8 tasks scheduled to run with org.quartz.threadPool.threadCount
set to 5.
但实际上我可以看到所有 8 个任务都在运行.
But in reality I can see that all 8 tasks are running.
这怎么可能?
如果我设置org.quartz.threadPool.threadCount=5
并且我为quartz提交了10个任务,是不是只有5个任务会并行运行?
If I set org.quartz.threadPool.threadCount=5
and I submitted 10 tasks for quartz, it is true that only 5 tasks will run in parallel?
org.quartz.threadPool.threadCount
属性是什么意思?
我有这样的设计:
- 我们有一些任务对 db 中的实体进行了一些工作
- 我们有专门的 JobRunner 来执行一项任务
- 我们扫描要运行的任务并安排在石英服务中运行的任务,该服务配置了 SchedulerFactoryBean,
org.quartz.threadPool.threadCount
设置为 5. - 据我所知,带有 SchedulerFactoryBean 的石英服务是否会运行 5 个任务,如果我们尝试安排额外的任务,石英本身应该抛出异常.这是真的吗?
谢谢.
推荐答案
QUARTZ 的 org.quartz.threadPool.threadCount 确实只是并发/并行执行的最大数量.
这意味着,如果您安排的 X 个作业大于 threadCount,那么 K = X - threadCount 个作业将最多等待 misFired 在某种队列中等待 threadCount 作业完成的毫秒数.
因此计划作业的总数(或任务)可能是队列中等待的任务数+正在运行的任务数.正在运行的任务数小于或等于threadCount.
It's true that QUARTZ's org.quartz.threadPool.threadCount is only the max number of concurrent/parallel execution.
That means that if you schedule X jobs greater than threadCount then K = X - threadCount jobs will wait at most a misFired milliseconds in some kind of queue for threadCount jobs to finish.
Thus Total number of scheduled jobs (or task) may be Number of waiting task in queue + Number of running task. With Number of running task less or equal to threadCount.
这篇关于Quartz 调度器最大线程数属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!