Package org.apache.flink.util.concurrent
Class ExecutorThreadFactory
- java.lang.Object
-
- org.apache.flink.util.concurrent.ExecutorThreadFactory
-
- All Implemented Interfaces:
ThreadFactory
public class ExecutorThreadFactory extends Object implements ThreadFactory
A thread factory intended for use by critical thread pools. Critical thread pools here mean thread pools that support Flink's core coordination and processing work, and which must not simply cause unnoticed errors.The thread factory can be given an
Thread.UncaughtExceptionHandler
for the threads. If no handler is explicitly given, the default handler for uncaught exceptions will log the exceptions and kill the process afterwards. That guarantees that critical exceptions are not accidentally lost and leave the system running in an inconsistent state.Threads created by this factory are all called '(pool-name)-thread-n', where (pool-name) is configurable, and n is an incrementing number.
All threads created by this factory are daemon threads and have the default (normal) priority.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExecutorThreadFactory.Builder
Builder forExecutorThreadFactory
.
-
Constructor Summary
Constructors Constructor Description ExecutorThreadFactory()
Creates a new thread factory using the default thread pool name ('flink-executor-pool') and the default uncaught exception handler (log exception and kill process).ExecutorThreadFactory(String poolName)
Creates a new thread factory using the given thread pool name and the default uncaught exception handler (log exception and kill process).ExecutorThreadFactory(String poolName, Thread.UncaughtExceptionHandler exceptionHandler)
Creates a new thread factory using the given thread pool name and the given uncaught exception handler.
-
-
-
Constructor Detail
-
ExecutorThreadFactory
public ExecutorThreadFactory()
Creates a new thread factory using the default thread pool name ('flink-executor-pool') and the default uncaught exception handler (log exception and kill process).
-
ExecutorThreadFactory
public ExecutorThreadFactory(String poolName)
Creates a new thread factory using the given thread pool name and the default uncaught exception handler (log exception and kill process).- Parameters:
poolName
- The pool name, used as the threads' name prefix
-
ExecutorThreadFactory
public ExecutorThreadFactory(String poolName, Thread.UncaughtExceptionHandler exceptionHandler)
Creates a new thread factory using the given thread pool name and the given uncaught exception handler.- Parameters:
poolName
- The pool name, used as the threads' name prefixexceptionHandler
- The uncaught exception handler for the threads
-
-
Method Detail
-
newThread
public Thread newThread(Runnable runnable)
- Specified by:
newThread
in interfaceThreadFactory
-
-