public final class StandardThreadFactory extends Object implements ThreadFactory
ThreadFactory
. The new
java.util.concurrency library provides a ThreadFactory
interface, which is a great
thing, but strangely enough it doesn't provide an customizable implementation.
If the maximum priority of the ThreadGroup is changed after this StandardThreadFactory is
constructed, then this will be ignored by the StandardThreadFactory. So it could be that a
StandardThreadFactory has a higher priority than the ThreadGroup allowed. What will happen at
construction?Constructor and Description |
---|
StandardThreadFactory()
Constructs a new StandardThreadFactory with a Thread.NORM_PRIORITY as priority and a newly
created ThreadGroup.
|
StandardThreadFactory(int priority)
Constructs a new StandardThreadFactory with the given priority.
|
StandardThreadFactory(int priority,
boolean daemon)
Creates a new StandardThreadFactory with the given priority and if the threads are daemons
|
StandardThreadFactory(int priority,
String groupName)
Constructs a new StandardThreadFactory with the given priority and with a newly created
ThreadGroup with the given groupName.
|
StandardThreadFactory(int priority,
ThreadGroup threadGroup)
Constructs a new StandardThreadFactory with the given priority and are part of the give
ThreadGroup.
|
StandardThreadFactory(int priority,
ThreadGroup threadGroup,
boolean daemon)
Constructs a new StandardThreadFactory with the given priority and ThreadGroup.
|
StandardThreadFactory(String groupName)
Constructs a new StandardThreadFactory with a Thread.NORM_PRIORITY as priority and with a
newly created ThreadGroup with the given groupName.
|
Modifier and Type | Method and Description |
---|---|
int |
getPriority()
Returns the priority of created Threads.
|
ThreadGroup |
getThreadGroup()
Returns the ThreadGroup of the created Threads.
|
boolean |
isProducingDaemons()
Returns true if this StandardThreadFactory is producing daemon threads, false
otherwise.
|
Thread |
newThread(Runnable runnable) |
void |
setPriority(int priority)
Sets the priority of the threads.
|
public StandardThreadFactory()
public StandardThreadFactory(String groupName)
groupName
- the name of the ThreadGroup (is allowed to be null).public StandardThreadFactory(int priority)
priority
- the priority of th threads.IllegalArgumentException
- if the priority is not valid.public StandardThreadFactory(int priority, String groupName)
priority
- the priority of the threads this StandardThreadFactory is going to createReference.groupName
- the name of the ThreadGroup (is allowed to be null).IllegalArgumentException
- if priority is not a valid value.public StandardThreadFactory(int priority, ThreadGroup threadGroup)
priority
- the priority of the created threads.threadGroup
- the ThreadGroup the created Threads are part of.NullPointerException
- if threadGroup is nullIllegalArgumentException
- if the priority is not valid value.public StandardThreadFactory(int priority, boolean daemon)
priority
- the priority of the thread.daemon
- if the thread is a daemon.public StandardThreadFactory(int priority, ThreadGroup threadGroup, boolean daemon)
priority
- the priority of the threads this StandardThreadFactory is going to createReference.threadGroup
- the ThreadGroup the thread is part ofdaemon
- if the thread should be a daemon.IllegalArgumentException
- if the priority is not valid.NullPointerException
- if threadGroup is null.public boolean isProducingDaemons()
public ThreadGroup getThreadGroup()
public int getPriority()
public void setPriority(int priority)
priority
- the new priority.IllegalArgumentException
- if priority is smaller than Thread.MIN_PRIORITY
or
larger than Thread.MAX_PRIORITY
or larger than the
maximum priority of the ThreadGroup.public Thread newThread(Runnable runnable)
newThread
in interface ThreadFactory
Copyright © 2020. All rights reserved.