Configuring the Scheduled Task Thread Pool

Tasks executed by @Scheduled are run by default on a ScheduledExecutorService configured to have twice the number of threads as available processors.

You can configure this thread pool using application.yml, for example:

Configuring Scheduled Task Thread Pool

  1. micronaut:
  2. executors:
  3. scheduled:
  4. type: scheduled
  5. core-pool-size: 30

🔗

Table 1. Configuration Properties for UserExecutorConfiguration
PropertyTypeDescription

micronaut.executors..n-threads

java.lang.Integer

micronaut.executors..type

ExecutorType

micronaut.executors..parallelism

java.lang.Integer

micronaut.executors..core-pool-size

java.lang.Integer

micronaut.executors..thread-factory-class

java.lang.Class

micronaut.executors..name

java.lang.String

Sets the executor name.

micronaut.executors..number-of-threads

java.lang.Integer

Sets the number of threads for FIXED. Default value (2 Number of processors available to the Java virtual machine).