Package io.microsphere.concurrent
Class CustomizedThreadFactory
- java.lang.Object
-
- io.microsphere.concurrent.CustomizedThreadFactory
-
- All Implemented Interfaces:
java.util.concurrent.ThreadFactory
public class CustomizedThreadFactory extends java.lang.Object implements java.util.concurrent.ThreadFactory
AThreadFactory
implementation that creates threads with customized attributes, including name prefix, daemon status, priority, and stack size.Example Usage
// Create a ThreadFactory with default settings ThreadFactory factory = CustomizedThreadFactory.newThreadFactory("worker"); // Create a ThreadFactory with custom daemon, priority, and stack size ThreadFactory customFactory = CustomizedThreadFactory.newThreadFactory("task", false, Thread.MAX_PRIORITY, 1024);
- Since:
- 1.0.0
- Author:
- Mercy
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEFAULT_DAEMON
The default value ofdaemon
static int
DEFAULT_PRIORITY
The default value ofpriority
static long
DEFAULT_STACK_SIZE
The default value ofstackSize
-
Constructor Summary
Constructors Modifier Constructor Description protected
CustomizedThreadFactory(java.lang.String namePrefix, boolean daemon, int priority, long stackSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Thread
newThread(java.lang.Runnable r)
static java.util.concurrent.ThreadFactory
newThreadFactory(java.lang.String namePrefix)
static java.util.concurrent.ThreadFactory
newThreadFactory(java.lang.String namePrefix, boolean daemon)
static java.util.concurrent.ThreadFactory
newThreadFactory(java.lang.String namePrefix, boolean daemon, int priority)
static java.util.concurrent.ThreadFactory
newThreadFactory(java.lang.String namePrefix, boolean daemon, int priority, long stackSize)
-
-
-
Field Detail
-
DEFAULT_DAEMON
public static final boolean DEFAULT_DAEMON
The default value ofdaemon
- See Also:
- Constant Field Values
-
DEFAULT_PRIORITY
public static final int DEFAULT_PRIORITY
The default value ofpriority
- See Also:
- Constant Field Values
-
DEFAULT_STACK_SIZE
public static final long DEFAULT_STACK_SIZE
The default value ofstackSize
- See Also:
- Constant Field Values
-
-
Method Detail
-
newThreadFactory
public static java.util.concurrent.ThreadFactory newThreadFactory(java.lang.String namePrefix)
-
newThreadFactory
public static java.util.concurrent.ThreadFactory newThreadFactory(java.lang.String namePrefix, boolean daemon)
-
newThreadFactory
public static java.util.concurrent.ThreadFactory newThreadFactory(java.lang.String namePrefix, boolean daemon, int priority)
-
newThreadFactory
public static java.util.concurrent.ThreadFactory newThreadFactory(java.lang.String namePrefix, boolean daemon, int priority, long stackSize)
-
newThread
public java.lang.Thread newThread(java.lang.Runnable r)
- Specified by:
newThread
in interfacejava.util.concurrent.ThreadFactory
-
-