Class Log4jThreadFactory
- java.lang.Object
-
- org.apache.logging.log4j.core.util.Log4jThreadFactory
-
- All Implemented Interfaces:
ThreadFactory
public class Log4jThreadFactory extends Object implements ThreadFactory
CreatesLog4jThread
s.- Since:
- 2.7
-
-
Constructor Summary
Constructors Constructor Description Log4jThreadFactory(String threadFactoryName, boolean daemon, int priority)
Constructs an initialized thread factory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Log4jThreadFactory
createDaemonThreadFactory(String threadFactoryName)
Creates a new daemon thread factory.static Log4jThreadFactory
createThreadFactory(String threadFactoryName)
Creates a new thread factory.Thread
newThread(Runnable runnable)
-
-
-
Constructor Detail
-
Log4jThreadFactory
public Log4jThreadFactory(String threadFactoryName, boolean daemon, int priority)
Constructs an initialized thread factory.- Parameters:
threadFactoryName
- The thread factory name.daemon
- Whether to create daemon threads.priority
- The thread priority.
-
-
Method Detail
-
createDaemonThreadFactory
public static Log4jThreadFactory createDaemonThreadFactory(String threadFactoryName)
Creates a new daemon thread factory.- Parameters:
threadFactoryName
- The thread factory name.- Returns:
- a new daemon thread factory.
-
createThreadFactory
public static Log4jThreadFactory createThreadFactory(String threadFactoryName)
Creates a new thread factory. This is mainly used for tests. Production code should be very careful with creating non-daemon threads since those will block application shutdown (see https://issues.apache.org/jira/browse/LOG4J2-1748).- Parameters:
threadFactoryName
- The thread factory name.- Returns:
- a new daemon thread factory.
-
newThread
public Thread newThread(Runnable runnable)
- Specified by:
newThread
in interfaceThreadFactory
-
-