public class NamedThreadFactory extends Object implements ThreadFactory
1. 自定义线程命名前缀 2. 自定义是否守护线程
Constructor and Description |
---|
NamedThreadFactory(String prefix,
boolean isDaemon)
构造
|
NamedThreadFactory(String prefix,
ThreadGroup threadGroup,
boolean isDaemon)
构造
|
NamedThreadFactory(String prefix,
ThreadGroup threadGroup,
boolean isDaemon,
Thread.UncaughtExceptionHandler handler)
构造
|
public NamedThreadFactory(String prefix, boolean isDaemon)
prefix
- 线程名前缀isDaemon
- 是否守护线程public NamedThreadFactory(String prefix, ThreadGroup threadGroup, boolean isDaemon)
prefix
- 线程名前缀threadGroup
- 线程组,可以为nullisDaemon
- 是否守护线程public NamedThreadFactory(String prefix, ThreadGroup threadGroup, boolean isDaemon, Thread.UncaughtExceptionHandler handler)
prefix
- 线程名前缀threadGroup
- 线程组,可以为nullisDaemon
- 是否守护线程handler
- 未捕获异常处理public Thread newThread(Runnable r)
newThread
in interface ThreadFactory
Copyright © 2024. All rights reserved.