Class ThreadCreator
java.lang.Object
com.iohao.net.common.kit.concurrent.ThreadCreator
- Direct Known Subclasses:
DaemonThreadFactory, FixedNameThreadFactory
Base class for creating threads with configurable name prefix, priority, daemon flag, and thread group.
- Author:
- 渔民小镇
- date:
- 2023-04-02
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected final AtomicIntegerprotected ThreadGroupprotected Stringprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateThread(Runnable runnable) Create a new thread with the configured group, name, priority, and daemon flag.protected StringGenerate the next thread name using the prefix and an auto-incrementing counter.voidsetThreadGroupName(String name) Set the thread group by name.
-
Field Details
-
threadNamePrefix
-
threadPriority
protected int threadPriority -
daemon
protected boolean daemon -
threadGroup
-
threadCount
-
-
Constructor Details
-
ThreadCreator
-
-
Method Details
-
setThreadGroupName
Set the thread group by name.- Parameters:
name- the thread group name
-
createThread
-
nextThreadName
Generate the next thread name using the prefix and an auto-incrementing counter.- Returns:
- the next thread name
-