public class ExecutorThreadFactory extends Object implements ThreadFactory
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.
| 限定符和类型 | 类和说明 |
|---|---|
static class |
ExecutorThreadFactory.Builder
Builder for
ExecutorThreadFactory. |
| 构造器和说明 |
|---|
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.
|
public ExecutorThreadFactory(String poolName)
poolName - The pool name, used as the threads' name prefixpublic ExecutorThreadFactory(String poolName, Thread.UncaughtExceptionHandler exceptionHandler)
poolName - The pool name, used as the threads' name prefixexceptionHandler - The uncaught exception handler for the threadspublic Thread newThread(Runnable runnable)
newThread 在接口中 ThreadFactoryCopyright © 2023 The Apache Software Foundation. All rights reserved.