java @Scheduled & scheduler:pool-size 到底是做什么的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4314323/
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
@Scheduled & scheduler: What exactly does pool-size do?
提问by chzbrgla
I want to run several scheduled Tasks simultaneously.
我想同时运行多个计划任务。
When configuring spring to do so, I can supply a pool-size to the scheduler:
在配置 spring 时,我可以为调度程序提供池大小:
<task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>
<task:executor id="myExecutor" pool-size="32"/>
<task:scheduler id="myScheduler" pool-size="1000"/>
But what exactly does the pool-size mean here?
但是池大小在这里究竟意味着什么?
Does it mean it can only store 1000 scheduled Methods or does it mean that only 1000 Methods can be processed at the same time?
这是否意味着它只能存储 1000 个调度方法,还是意味着只能同时处理 1000 个方法?
tldr;If a @Scheduled(fixedDelay=60) annotated Method is NOTexecuted at the moment (meaning it's in between the delay), does it fill up the pool or not?
tldr; 如果@Scheduled(fixedDelay=60) 注释的方法目前没有执行(意味着它在延迟之间),它是否填满了池?
采纳答案by GaryF
It refers to the number of threads that can be pooled at once by the underlying ThreadPoolExecutor i.e. the notional number of methods that can be run at the same time.
它指的是底层 ThreadPoolExecutor 可以一次汇集的线程数,即可以同时运行的方法的名义数量。
The documentation on the task namespacegoes into a lot of the detail you need.
任务命名空间的文档包含了许多您需要的细节。
I expect that 1000 threads is probably going to be far too many in most environments.
我预计在大多数环境中 1000 个线程可能会太多。