Package org.uncommons.util.concurrent
Class ConfigurableThreadFactory
- java.lang.Object
-
- org.uncommons.util.concurrent.ConfigurableThreadFactory
-
- All Implemented Interfaces:
ThreadFactory
public class ConfigurableThreadFactory extends Object implements ThreadFactory
Thread factory that creates threads for use by aThreadPoolExecutor. The factory can be configured to customise the names, priority and daemon status of created threads.
-
-
Constructor Summary
Constructors Constructor Description ConfigurableThreadFactory(String namePrefix, int priority, boolean daemon)ConfigurableThreadFactory(String namePrefix, int priority, boolean daemon, Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThreadnewThread(Runnable runnable)Creates a new thread configured according to this factory's parameters.
-
-
-
Constructor Detail
-
ConfigurableThreadFactory
public ConfigurableThreadFactory(String namePrefix, int priority, boolean daemon)
- Parameters:
namePrefix- The String prefix used to assign identifiers to created threads.priority- The initial priority for created threads.daemon- Whether or not created threads should be daemon threads or user threads. The JVM exits when the only threads running are all daemon threads.
-
ConfigurableThreadFactory
public ConfigurableThreadFactory(String namePrefix, int priority, boolean daemon, Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
- Parameters:
namePrefix- The String prefix used to assign identifiers to created threads.priority- The initial priority for created threads.daemon- Whether or not created threads should be daemon threads or user threads. The JVM exits when the only threads running are all daemon threads.uncaughtExceptionHandler- A strategy for dealing with uncaught exceptions.
-
-
Method Detail
-
newThread
public Thread newThread(Runnable runnable)
Creates a new thread configured according to this factory's parameters.- Specified by:
newThreadin interfaceThreadFactory- Parameters:
runnable- The runnable to be executed by the new thread.- Returns:
- The created thread.
-
-