Class SimpleAsyncTaskExecutorBuilder

java.lang.Object
org.springframework.boot.task.SimpleAsyncTaskExecutorBuilder

public class SimpleAsyncTaskExecutorBuilder extends Object
Builder that can be used to configure and create a SimpleAsyncTaskExecutor. Provides convenience methods to set common SimpleAsyncTaskExecutor settings and register taskDecorator(TaskDecorator)). For advanced configuration, consider using SimpleAsyncTaskExecutorCustomizer.

In a typical auto-configured Spring Boot application this builder is available as a bean and can be injected whenever a SimpleAsyncTaskExecutor is needed.

Since:
3.2.0
  • Constructor Details

    • SimpleAsyncTaskExecutorBuilder

      public SimpleAsyncTaskExecutorBuilder()
  • Method Details

    • threadNamePrefix

      public SimpleAsyncTaskExecutorBuilder threadNamePrefix(String threadNamePrefix)
      Set the prefix to use for the names of newly created threads.
      Parameters:
      threadNamePrefix - the thread name prefix to set
      Returns:
      a new builder instance
    • virtualThreads

      public SimpleAsyncTaskExecutorBuilder virtualThreads(Boolean virtualThreads)
      Set whether to use virtual threads.
      Parameters:
      virtualThreads - whether to use virtual threads
      Returns:
      a new builder instance
    • concurrencyLimit

      public SimpleAsyncTaskExecutorBuilder concurrencyLimit(Integer concurrencyLimit)
      Set the concurrency limit.
      Parameters:
      concurrencyLimit - the concurrency limit
      Returns:
      a new builder instance
    • taskDecorator

      public SimpleAsyncTaskExecutorBuilder taskDecorator(org.springframework.core.task.TaskDecorator taskDecorator)
      Set the TaskDecorator to use or null to not use any.
      Parameters:
      taskDecorator - the task decorator to use
      Returns:
      a new builder instance
    • taskTerminationTimeout

      public SimpleAsyncTaskExecutorBuilder taskTerminationTimeout(Duration taskTerminationTimeout)
      Set the task termination timeout.
      Parameters:
      taskTerminationTimeout - the task termination timeout
      Returns:
      a new builder instance
      Since:
      3.2.1
    • customizers

      Set the customizers that should be applied to the SimpleAsyncTaskExecutor. Customizers are applied in the order that they were added after builder configuration has been applied. Setting this value will replace any previously configured customizers.
      Parameters:
      customizers - the customizers to set
      Returns:
      a new builder instance
      See Also:
    • customizers

      public SimpleAsyncTaskExecutorBuilder customizers(Iterable<? extends SimpleAsyncTaskExecutorCustomizer> customizers)
      Set the customizers that should be applied to the SimpleAsyncTaskExecutor. Customizers are applied in the order that they were added after builder configuration has been applied. Setting this value will replace any previously configured customizers.
      Parameters:
      customizers - the customizers to set
      Returns:
      a new builder instance
      See Also:
    • additionalCustomizers

      public SimpleAsyncTaskExecutorBuilder additionalCustomizers(SimpleAsyncTaskExecutorCustomizer... customizers)
      Add customizers that should be applied to the SimpleAsyncTaskExecutor. Customizers are applied in the order that they were added after builder configuration has been applied.
      Parameters:
      customizers - the customizers to add
      Returns:
      a new builder instance
      See Also:
    • additionalCustomizers

      public SimpleAsyncTaskExecutorBuilder additionalCustomizers(Iterable<? extends SimpleAsyncTaskExecutorCustomizer> customizers)
      Add customizers that should be applied to the SimpleAsyncTaskExecutor. Customizers are applied in the order that they were added after builder configuration has been applied.
      Parameters:
      customizers - the customizers to add
      Returns:
      a new builder instance
      See Also:
    • build

      public org.springframework.core.task.SimpleAsyncTaskExecutor build()
      Build a new SimpleAsyncTaskExecutor instance and configure it using this builder.
      Returns:
      a configured SimpleAsyncTaskExecutor instance.
      See Also:
    • build

      public <T extends org.springframework.core.task.SimpleAsyncTaskExecutor> T build(Class<T> taskExecutorClass)
      Build a new SimpleAsyncTaskExecutor instance of the specified type and configure it using this builder.
      Type Parameters:
      T - the type of task executor
      Parameters:
      taskExecutorClass - the template type to create
      Returns:
      a configured SimpleAsyncTaskExecutor instance.
      See Also:
    • configure

      public <T extends org.springframework.core.task.SimpleAsyncTaskExecutor> T configure(T taskExecutor)
      Configure the provided SimpleAsyncTaskExecutor instance using this builder.
      Type Parameters:
      T - the type of task executor
      Parameters:
      taskExecutor - the SimpleAsyncTaskExecutor to configure
      Returns:
      the task executor instance
      See Also: