org.springframework.util

## 类 CustomizableThreadCreator

- java.lang.Object
- - org.springframework.util.CustomizableThreadCreator

- 所有已实现的接口:
    Serializable
  直接已知子类:
    SimpleAsyncTaskExecutor

      public class CustomizableThreadCreator
      extends Object
      implements Serializable

  Simple customizable helper class for creating new `Thread` instances. Provides various bean properties: thread name prefix, thread priority, etc.

  Serves as base class for thread factories such as `org.springframework.scheduling.concurrent.CustomizableThreadFactory`.

  从以下版本开始:
    2.0.3
  作者:
    Juergen Hoeller
  另请参阅:
    `org.springframework.scheduling.concurrent.CustomizableThreadFactory`, 序列化表格

- - ### 构造器概要

    构造器
    构造器和说明
    `CustomizableThreadCreator()` Create a new CustomizableThreadCreator with default thread name prefix.
    `CustomizableThreadCreator(String threadNamePrefix)` Create a new CustomizableThreadCreator with the given thread name prefix.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `Thread` | `createThread(Runnable runnable)` Template method for the creation of a new `Thread`.
    `protected String` | `getDefaultThreadNamePrefix()` Build the default thread name prefix for this factory.
    `ThreadGroup` | `getThreadGroup()` Return the thread group that threads should be created in (or `null` for the default group).
    `String` | `getThreadNamePrefix()` Return the thread name prefix to use for the names of newly created threads.
    `int` | `getThreadPriority()` Return the priority of the threads that this factory creates.
    `boolean` | `isDaemon()` Return whether this factory should create daemon threads.
    `protected String` | `nextThreadName()` Return the thread name to use for a newly created `Thread`.
    `void` | `setDaemon(boolean daemon)` Set whether this factory is supposed to create daemon threads, just executing as long as the application itself is running.
    `void` | `setThreadGroup(ThreadGroup threadGroup)` Specify the thread group that threads should be created in.
    `void` | `setThreadGroupName(String name)` Specify the name of the thread group that threads should be created in.
    `void` | `setThreadNamePrefix(String threadNamePrefix)` Specify the prefix to use for the names of newly created threads.
    `void` | `setThreadPriority(int threadPriority)` Set the priority of the threads that this factory creates.

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

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

- - ### 构造器详细资料

    - #### CustomizableThreadCreator

          public CustomizableThreadCreator()

      Create a new CustomizableThreadCreator with default thread name prefix.

    - #### CustomizableThreadCreator

          public CustomizableThreadCreator(@Nullable
                                           String threadNamePrefix)

      Create a new CustomizableThreadCreator with the given thread name prefix.
      参数:
        `threadNamePrefix` - the prefix to use for the names of newly created threads

  - ### 方法详细资料

    - #### setThreadNamePrefix

          public void setThreadNamePrefix(@Nullable
                                          String threadNamePrefix)

      Specify the prefix to use for the names of newly created threads. Default is "SimpleAsyncTaskExecutor-".

    - #### getThreadNamePrefix

          public String getThreadNamePrefix()

      Return the thread name prefix to use for the names of newly created threads.

    - #### setThreadPriority

          public void setThreadPriority(int threadPriority)

      Set the priority of the threads that this factory creates. Default is 5.
      另请参阅:
        `Thread.NORM_PRIORITY`

    - #### getThreadPriority

          public int getThreadPriority()

      Return the priority of the threads that this factory creates.

    - #### setDaemon

          public void setDaemon(boolean daemon)

      Set whether this factory is supposed to create daemon threads, just executing as long as the application itself is running.

      Default is "false": Concrete factories usually support explicit cancelling. Hence, if the application shuts down, Runnables will by default finish their execution.

      Specify "true" for eager shutdown of threads which still actively execute a `Runnable` at the time that the application itself shuts down.

      另请参阅:
        `Thread.setDaemon(boolean)`

    - #### isDaemon

          public boolean isDaemon()

      Return whether this factory should create daemon threads.

    - #### setThreadGroupName

          public void setThreadGroupName(String name)

      Specify the name of the thread group that threads should be created in.
      另请参阅:
        `setThreadGroup(java.lang.ThreadGroup)`

    - #### setThreadGroup

          public void setThreadGroup(@Nullable
                                     ThreadGroup threadGroup)

      Specify the thread group that threads should be created in.
      另请参阅:
        `setThreadGroupName(java.lang.String)`

    - #### getThreadGroup

          @Nullable
          public ThreadGroup getThreadGroup()

      Return the thread group that threads should be created in (or `null` for the default group).

    - #### createThread

          public Thread createThread(Runnable runnable)

      Template method for the creation of a new `Thread`.

      The default implementation creates a new Thread for the given `Runnable`, applying an appropriate thread name.

      参数:
        `runnable` - the Runnable to execute
      另请参阅:
        `nextThreadName()`

    - #### nextThreadName

          protected String nextThreadName()

      Return the thread name to use for a newly created `Thread`.

      The default implementation returns the specified thread name prefix with an increasing thread count appended: e.g. "SimpleAsyncTaskExecutor-0".

      另请参阅:
        `getThreadNamePrefix()`

    - #### getDefaultThreadNamePrefix

          protected String getDefaultThreadNamePrefix()

      Build the default thread name prefix for this factory.
      返回:
        the default thread name prefix (never `null`)