public class NamedThreadFactory extends Object implements ThreadFactory
ThreadFactory
implementation that allows
the user to specify a prefix name for each thread. This is useful for an
application that has multiple thread pools, to distinguish the pools in
a thread dump.
All threads created by this factory are named "PREFIX-thread-NN
",
where PREFIX is provided by the caller, and NN is an auto-incremented number
starting with 0.
Constructor and Description |
---|
NamedThreadFactory(String prefix)
A factory that creates daemon threads with NORMAL priority, belonging to
the thread group of the thread that created the factory.
|
NamedThreadFactory(String prefix,
ThreadGroup group,
int priority,
boolean isDaemon)
A factory that allows complete control over the threads created.
|
public NamedThreadFactory(String prefix)
public NamedThreadFactory(String prefix, ThreadGroup group, int priority, boolean isDaemon)
prefix
- Initial component of name for created threads.group
- Thread group to which created threads belong.priority
- Priority of created threads.isDaemon
- Whether or not created threads are daemons (ie,
whether they will keep the JVM running).public Thread newThread(Runnable r)
newThread
in interface ThreadFactory