public final class NamedThreadFactory extends Object implements ThreadFactory
| Modifier and Type | Field and Description |
|---|---|
private ThreadGroup |
group
The thread group either from the security manager
or from the current thread.
|
private String |
namePrefix
The name prefix of the form
<threadname>-javaoctave-<prefix>-<POOLNUMBER>-,
where <threadname> is the name of the current thread,
<prefix> is the prefix given by a parameter
of the constructor NamedThreadFactory(String)
and <POOLNUMBER> is POOL_NUMBER
depending on the factory object. |
private static AtomicInteger |
POOL_NUMBER
This is initialized with 1
and read and incremented only if a factory object is created.
|
private AtomicInteger |
threadNumber
The number of the thread created next by this factory starting with one
and being incremented by method
newThread(Runnable). |
| Modifier | Constructor and Description |
|---|---|
|
NamedThreadFactory() |
private |
NamedThreadFactory(String prefix)
Will create a factory that create Threads with the names:
[parent]-javaoctave-[prefix]-[pool#]-[thread#]. |
| Modifier and Type | Method and Description |
|---|---|
Thread |
newThread(Runnable runnable)
Returns a new thread with standard priority which is no daemon
from
runnable
with name consisting of namePrefix and a running number
threadNumber. |
private static final AtomicInteger POOL_NUMBER
private final ThreadGroup group
private final String namePrefix
<threadname>-javaoctave-<prefix>-<POOLNUMBER>-,
where <threadname> is the name of the current thread,
<prefix> is the prefix given by a parameter
of the constructor NamedThreadFactory(String)
and <POOLNUMBER> is POOL_NUMBER
depending on the factory object.
The trailing - is there because a new thread
defined by newThread(Runnable) obtains a name
consisting of the prefix followed by threadNumber.private final AtomicInteger threadNumber
newThread(Runnable).private NamedThreadFactory(String prefix)
[parent]-javaoctave-[prefix]-[pool#]-[thread#].
Here, [parent] is the name of the parent thread,
i.e. of the current thread,
[prefix] is given by the parameter
[pool#] is the number of this factory
and [thread#] refers to the number of the thread
created by this factory.prefix - public NamedThreadFactory()
public Thread newThread(Runnable runnable)
runnable
with name consisting of namePrefix and a running number
threadNumber.newThread in interface ThreadFactoryrunnable - the runnable to create a thread from.Copyright © 2006–2018 Simuline Organization (l2r). All rights reserved.