类 CustomizableThreadCreator
java.lang.Object
cn.taketoday.util.CustomizableThreadCreator
- 所有已实现的接口:
Serializable
- 直接已知子类:
SimpleAsyncTaskExecutor
Simple customizable helper class for creating new
Thread instances.
Provides various bean properties: thread name prefix, thread priority, etc.- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, TODAY 2021/9/11 15:44
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private booleanprivate final AtomicIntegerprivate ThreadGroupprivate Stringprivate int -
构造器概要
构造器构造器说明Create a new CustomizableThreadCreator with default thread name prefix.CustomizableThreadCreator(String threadNamePrefix) Create a new CustomizableThreadCreator with the given thread name prefix. -
方法概要
修饰符和类型方法说明createThread(Runnable runnable) Template method for the creation of a newThread.protected StringBuild the default thread name prefix for this factory.Return the thread group that threads should be created in (ornullfor the default group).Return the thread name prefix to use for the names of newly created threads.intReturn the priority of the threads that this factory creates.booleanisDaemon()Return whether this factory should create daemon threads.protected StringReturn the thread name to use for a newly createdThread.voidsetDaemon(boolean daemon) Set whether this factory is supposed to create daemon threads, just executing as long as the application itself is running.voidsetThreadGroup(ThreadGroup threadGroup) Specify the thread group that threads should be created in.voidsetThreadGroupName(String name) Specify the name of the thread group that threads should be created in.voidsetThreadNamePrefix(String threadNamePrefix) Specify the prefix to use for the names of newly created threads.voidsetThreadPriority(int threadPriority) Set the priority of the threads that this factory creates.
-
字段详细资料
-
threadNamePrefix
-
threadPriority
private int threadPriority -
daemon
private boolean daemon -
threadGroup
-
threadCount
-
-
构造器详细资料
-
CustomizableThreadCreator
public CustomizableThreadCreator()Create a new CustomizableThreadCreator with default thread name prefix. -
CustomizableThreadCreator
Create a new CustomizableThreadCreator with the given thread name prefix.- 参数:
threadNamePrefix- the prefix to use for the names of newly created threads
-
-
方法详细资料
-
setThreadNamePrefix
Specify the prefix to use for the names of newly created threads. Default is "SimpleAsyncTaskExecutor-". -
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.- 另请参阅:
-
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
Runnableat the time that the application itself shuts down. -
isDaemon
public boolean isDaemon()Return whether this factory should create daemon threads. -
setThreadGroupName
Specify the name of the thread group that threads should be created in. -
setThreadGroup
Specify the thread group that threads should be created in. -
getThreadGroup
Return the thread group that threads should be created in (ornullfor the default group). -
createThread
Template method for the creation of a newThread.The default implementation creates a new Thread for the given
Runnable, applying an appropriate thread name.- 参数:
runnable- the Runnable to execute- 另请参阅:
-
nextThreadName
Return the thread name to use for a newly createdThread.The default implementation returns the specified thread name prefix with an increasing thread count appended: e.g. "SimpleAsyncTaskExecutor-0".
- 另请参阅:
-
getDefaultThreadNamePrefix
Build the default thread name prefix for this factory.- 返回:
- the default thread name prefix (never
null)
-