6

I want to run several scheduled Tasks simultaneously.

When configuring spring to do so, I can supply a pool-size to the scheduler:

<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?

tldr; If a @Scheduled(fixedDelay=60) annotated Method is NOT executed at the moment (meaning it's in between the delay), does it fill up the pool or not?

chzbrgla
  • 5,158
  • 7
  • 39
  • 56

1 Answers1

5

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.

The documentation on the task namespace goes into a lot of the detail you need.

I expect that 1000 threads is probably going to be far too many in most environments.

GaryF
  • 23,950
  • 10
  • 60
  • 73
  • So it's not pooled until execution? When execution has finished, the corresponding thread is removed from the pool until the next execution? – chzbrgla Nov 30 '10 at 14:04
  • 2
    The documentation isn't specific about what `pool-size` means, but usually, it means the total number of threads that will be exist at any time. Some of those may be busy, and some may be idle, but all are considered to be in the pool. – Tom Anderson Nov 30 '10 at 15:09
  • @Tom - You're correct about how the pool will work, but the documentation is pretty specific: it uses ThreadPoolTaskExecutor and pool size is passed to that. – GaryF Nov 30 '10 at 15:20
  • 1
    fair enough; it doesn't lay it out in huge type right there for the benefit of lazy people like me, but it certainly does specify it by reference to ThreadPoolTaskScheduler and ThreadPoolTaskExecutor. – Tom Anderson Nov 30 '10 at 17:22