public class NamedThreadFactory
extends java.lang.Object
implements java.util.concurrent.ThreadFactory
ThreadFactory
that sets names to the threads created by this factory. Threads created by this factory
will take names in the form of the string namePrefix + " thread-" + threadNum
where threadNum is the
count of threads created by this type of factory.Modifier and Type | Field and Description |
---|---|
private java.lang.String |
namePrefix |
private static java.util.concurrent.atomic.AtomicInteger |
threadNumber |
Constructor and Description |
---|
NamedThreadFactory(java.lang.String namePrefix)
Constructor accepting the prefix of the threads that will be created by this
ThreadFactory |
Modifier and Type | Method and Description |
---|---|
java.lang.Thread |
newThread(java.lang.Runnable runnable)
Returns a new thread using a name as specified by this factory
|
private static java.util.concurrent.atomic.AtomicInteger threadNumber
private final java.lang.String namePrefix