Package dev.brachtendorf.concurrency
Class NamedThreadFactory
- java.lang.Object
-
- dev.brachtendorf.concurrency.NamedThreadFactory
-
- All Implemented Interfaces:
ThreadFactory
public class NamedThreadFactory extends Object implements ThreadFactory
Analogous implementation of the default thread factory used by java executors. This Factory allows to set the naming pattern, daemon support and exception handlers for all threads spawned. The current thread group is inherited.- Since:
- 1.1.0 com.github.kilianB
- Author:
- Kilian
-
-
Constructor Summary
Constructors Constructor Description NamedThreadFactory()A thread factory creating non daemon threads.NamedThreadFactory(boolean daemon)A thread factory spawning threads with the threads factory default uncaught exception handler.NamedThreadFactory(String namePrefix)A thread factory creating non daemon threads.NamedThreadFactory(String namePrefix, boolean daemon)Create a new thread factory with advanced settings.NamedThreadFactory(String namePrefix, boolean daemon, Thread.UncaughtExceptionHandler handler)A thread factory with advanced settings.NamedThreadFactory(String namePrefix, Thread.UncaughtExceptionHandler handler)A thread factory creating non daemon threadsNamedThreadFactory(Thread.UncaughtExceptionHandler handler)A thread factory creating non daemon threads.
-
-
-
Constructor Detail
-
NamedThreadFactory
public NamedThreadFactory()
A thread factory creating non daemon threads. A default uncaught exception handler is attached to every thread spawned.
-
NamedThreadFactory
public NamedThreadFactory(boolean daemon)
A thread factory spawning threads with the threads factory default uncaught exception handler.- Parameters:
daemon- weather or not the created threads are daemon threads.
-
NamedThreadFactory
public NamedThreadFactory(Thread.UncaughtExceptionHandler handler)
A thread factory creating non daemon threads.- Parameters:
handler- Exception handler attached to every created thread
-
NamedThreadFactory
public NamedThreadFactory(String namePrefix)
A thread factory creating non daemon threads. The thread factories default uncaught exception handler is attached to every thread created.- Parameters:
namePrefix- prefixed to name threads created by this factory. Threads will be named namePrefix-thread#. If null or empty a pattern of pool-pool#-thread# is applied.
-
NamedThreadFactory
public NamedThreadFactory(String namePrefix, boolean daemon)
Create a new thread factory with advanced settings. A default uncaught exception handler is attached to every thread created.- Parameters:
namePrefix- prefixed to name threads created by this factory. Threads will be named namePrefix-thread#. If null or empty a pattern of pool-pool#-thread# is applied.daemon- weather or not the created threads are daemon threads.
-
NamedThreadFactory
public NamedThreadFactory(String namePrefix, Thread.UncaughtExceptionHandler handler)
A thread factory creating non daemon threads- Parameters:
namePrefix- namePrefix prefixed to name threads created by this factory. Threads will be named namePrefix-thread#. If null or empty a pattern of pool-pool#-thread# is applied.handler- Exception handler attached to every created thread
-
NamedThreadFactory
public NamedThreadFactory(String namePrefix, boolean daemon, Thread.UncaughtExceptionHandler handler)
A thread factory with advanced settings.- Parameters:
namePrefix- namePrefix prefixed to name threads created by this factory. Threads will be named namePrefix-thread#. If null or empty a pattern of pool-pool#-thread# is applied.handler- Exception handler attached to every created threaddaemon- weather or not the created threads are daemon threads.
-
-
Method Detail
-
newThread
public Thread newThread(Runnable r)
- Specified by:
newThreadin interfaceThreadFactory
-
-