org.springframework.scheduling.concurrent

## 类 ExecutorConfigurationSupport

- java.lang.Object
- - org.springframework.util.CustomizableThreadCreator
  - - org.springframework.scheduling.concurrent.CustomizableThreadFactory
    - - org.springframework.scheduling.concurrent.ExecutorConfigurationSupport

- 所有已实现的接口:
    Serializable, ThreadFactory, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean
  直接已知子类:
    ScheduledExecutorFactoryBean, ThreadPoolExecutorFactoryBean, ThreadPoolTaskExecutor, ThreadPoolTaskScheduler

      public abstract class ExecutorConfigurationSupport
      extends CustomizableThreadFactory
      implements org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

  Base class for setting up a `ExecutorService` (typically a `ThreadPoolExecutor` or `ScheduledThreadPoolExecutor`). Defines common configuration settings and common lifecycle handling.
  从以下版本开始:
    3.0
  作者:
    Juergen Hoeller
  另请参阅:
    `ExecutorService`, `Executors`, `ThreadPoolExecutor`, `ScheduledThreadPoolExecutor`, 序列化表格

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected Log` | `logger`

  - ### 构造器概要

    构造器
    构造器和说明
    `ExecutorConfigurationSupport()`

  - ### 方法概要

    所有方法 实例方法 抽象方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `afterPropertiesSet()` Calls `initialize()` after the container applied all property values.
    `protected void` | `cancelRemainingTask(Runnable task)` Cancel the given remaining task which never commended execution, as returned from `ExecutorService.shutdownNow()`.
    `void` | `destroy()` Calls `shutdown` when the BeanFactory destroys the task executor instance.
    `void` | `initialize()` Set up the ExecutorService.
    `protected abstract ExecutorService` | `initializeExecutor(ThreadFactory threadFactory, RejectedExecutionHandler rejectedExecutionHandler)` Create the target `ExecutorService` instance.
    `void` | `setAwaitTerminationSeconds(int awaitTerminationSeconds)` Set the maximum number of seconds that this executor is supposed to block on shutdown in order to wait for remaining tasks to complete their execution before the rest of the container continues to shut down.
    `void` | `setBeanName(String name)`
    `void` | `setRejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler)` Set the RejectedExecutionHandler to use for the ExecutorService.
    `void` | `setThreadFactory(ThreadFactory threadFactory)` Set the ThreadFactory to use for the ExecutorService's thread pool.
    `void` | `setThreadNamePrefix(String threadNamePrefix)`
    `void` | `setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown)` Set whether to wait for scheduled tasks to complete on shutdown, not interrupting running tasks and executing all tasks in the queue.
    `void` | `shutdown()` Perform a shutdown on the underlying ExecutorService.

    - ### 从类继承的方法 org.springframework.scheduling.concurrent.CustomizableThreadFactory

      `newThread`

    - ### 从类继承的方法 org.springframework.util.CustomizableThreadCreator

      `createThread, getDefaultThreadNamePrefix, getThreadGroup, getThreadNamePrefix, getThreadPriority, isDaemon, nextThreadName, setDaemon, setThreadGroup, setThreadGroupName, setThreadPriority`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 字段详细资料

    - #### logger

          protected final Log logger

  - ### 构造器详细资料

    - #### ExecutorConfigurationSupport

          public ExecutorConfigurationSupport()

  - ### 方法详细资料

    - #### setThreadFactory

          public void setThreadFactory(@Nullable
                                       ThreadFactory threadFactory)

      Set the ThreadFactory to use for the ExecutorService's thread pool. Default is the underlying ExecutorService's default thread factory.

      In a Java EE 7 or other managed environment with JSR-236 support, consider specifying a JNDI-located ManagedThreadFactory: by default, to be found at "java:comp/DefaultManagedThreadFactory". Use the "jee:jndi-lookup" namespace element in XML or the programmatic `JndiLocatorDelegate` for convenient lookup. Alternatively, consider using Spring's `DefaultManagedAwareThreadFactory` with its fallback to local threads in case of no managed thread factory found.

      另请参阅:
        `Executors.defaultThreadFactory()`, `ManagedThreadFactory`, `DefaultManagedAwareThreadFactory`

    - #### setThreadNamePrefix

          public void setThreadNamePrefix(@Nullable
                                          String threadNamePrefix)

      覆盖:
        `setThreadNamePrefix` 在类中 `org.springframework.util.CustomizableThreadCreator`

    - #### setRejectedExecutionHandler

          public void setRejectedExecutionHandler(@Nullable
                                                  RejectedExecutionHandler rejectedExecutionHandler)

      Set the RejectedExecutionHandler to use for the ExecutorService. Default is the ExecutorService's default abort policy.
      另请参阅:
        `ThreadPoolExecutor.AbortPolicy`

    - #### setWaitForTasksToCompleteOnShutdown

          public void setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown)

      Set whether to wait for scheduled tasks to complete on shutdown, not interrupting running tasks and executing all tasks in the queue.

      Default is "false", shutting down immediately through interrupting ongoing tasks and clearing the queue. Switch this flag to "true" if you prefer fully completed tasks at the expense of a longer shutdown phase.

      Note that Spring's container shutdown continues while ongoing tasks are being completed. If you want this executor to block and wait for the termination of tasks before the rest of the container continues to shut down - e.g. in order to keep up other resources that your tasks may need -, set the `"awaitTerminationSeconds"` property instead of or in addition to this property.

      另请参阅:
        `ExecutorService.shutdown()`, `ExecutorService.shutdownNow()`

    - #### setAwaitTerminationSeconds

          public void setAwaitTerminationSeconds(int awaitTerminationSeconds)

      Set the maximum number of seconds that this executor is supposed to block on shutdown in order to wait for remaining tasks to complete their execution before the rest of the container continues to shut down. This is particularly useful if your remaining tasks are likely to need access to other resources that are also managed by the container.

      By default, this executor won't wait for the termination of tasks at all. It will either shut down immediately, interrupting ongoing tasks and clearing the remaining task queue - or, if the `"waitForTasksToCompleteOnShutdown"` flag has been set to `true`, it will continue to fully execute all ongoing tasks as well as all remaining tasks in the queue, in parallel to the rest of the container shutting down.

      In either case, if you specify an await-termination period using this property, this executor will wait for the given time (max) for the termination of tasks. As a rule of thumb, specify a significantly higher timeout here if you set "waitForTasksToCompleteOnShutdown" to `true` at the same time, since all remaining tasks in the queue will still get executed - in contrast to the default shutdown behavior where it's just about waiting for currently executing tasks that aren't reacting to thread interruption.

      另请参阅:
        `ExecutorService.shutdown()`, `ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)`

    - #### setBeanName

          public void setBeanName(String name)

      指定者:
        `setBeanName` 在接口中 `org.springframework.beans.factory.BeanNameAware`

    - #### afterPropertiesSet

          public void afterPropertiesSet()

      Calls `initialize()` after the container applied all property values.
      指定者:
        `afterPropertiesSet` 在接口中 `org.springframework.beans.factory.InitializingBean`
      另请参阅:
        `initialize()`

    - #### initialize

          public void initialize()

      Set up the ExecutorService.

    - #### initializeExecutor

          protected abstract ExecutorService initializeExecutor(ThreadFactory threadFactory,
                                                                RejectedExecutionHandler rejectedExecutionHandler)

      Create the target `ExecutorService` instance. Called by `afterPropertiesSet`.
      参数:
        `threadFactory` - the ThreadFactory to use
        `rejectedExecutionHandler` - the RejectedExecutionHandler to use
      返回:
        a new ExecutorService instance
      另请参阅:
        `afterPropertiesSet()`

    - #### destroy

          public void destroy()

      Calls `shutdown` when the BeanFactory destroys the task executor instance.
      指定者:
        `destroy` 在接口中 `org.springframework.beans.factory.DisposableBean`
      另请参阅:
        `shutdown()`

    - #### shutdown

          public void shutdown()

      Perform a shutdown on the underlying ExecutorService.
      另请参阅:
        `ExecutorService.shutdown()`, `ExecutorService.shutdownNow()`

    - #### cancelRemainingTask

          protected void cancelRemainingTask(Runnable task)

      Cancel the given remaining task which never commended execution, as returned from `ExecutorService.shutdownNow()`.
      参数:
        `task` - the task to cancel (typically a `RunnableFuture`)
      从以下版本开始:
        5.0.5
      另请参阅:
        `shutdown()`, `Future.cancel(boolean)`