Configuring the Scheduled Task Thread Pool

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

You can configure this thread pool as desired 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..name

java.lang.String

Sets the executor name.

micronaut.executors..n-threads

java.lang.Integer

micronaut.executors..type

ExecutorType

Sets the executor type. Default value (SCHEDULED).

micronaut.executors..parallelism

java.lang.Integer

Sets the parallelism for WORK_STEALING. Default value (Number of processors available to the Java virtual machine).

micronaut.executors..core-pool-size

java.lang.Integer

Sets the core pool size for SCHEDULED. Default value (2 Number of processors available to the Java virtual machine).

micronaut.executors..thread-factory-class

java.lang.Class

Sets the thread factory class.

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).