public class ThreadGroup extends Object implements Thread.UncaughtExceptionHandler
Thread
,
SecurityManager
Constructor and Description |
---|
ThreadGroup(String name)
Constructs a new ThreadGroup with the name provided.
|
ThreadGroup(ThreadGroup parent,
String name)
Constructs a new ThreadGroup with the name provided, as child of
the ThreadGroup
parent |
Modifier and Type | Method and Description |
---|---|
int |
activeCount()
Returns the number of Threads which are children of
the receiver, directly or indirectly.
|
int |
activeGroupCount()
Returns the number of ThreadGroups which are children of
the receiver, directly or indirectly.
|
boolean |
allowThreadSuspension(boolean b)
Deprecated.
Required deprecated method suspend().
|
void |
checkAccess()
If there is a SecurityManager installed, call
checkAccess
in it passing the receiver as parameter, otherwise do nothing. |
void |
destroy()
Destroys the receiver and recursively all its subgroups.
|
int |
enumerate(Thread[] threads)
Copies an array with all Threads which are children of
the receiver (directly or indirectly) into the array
threads
passed as parameters. |
int |
enumerate(Thread[] threads,
boolean recurse)
Copies an array with all Threads which are children of
the receiver into the array
threads
passed as parameter. |
int |
enumerate(ThreadGroup[] groups)
Copies an array with all ThreadGroups which are children of
the receiver (directly or indirectly) into the array
groups
passed as parameters. |
int |
enumerate(ThreadGroup[] groups,
boolean recurse)
Copies an array with all ThreadGroups which are children of
the receiver into the array
groups
passed as parameter. |
int |
getMaxPriority()
Answers the maximum allowed priority for a Thread in the receiver.
|
String |
getName()
Answers the name of the receiver.
|
ThreadGroup |
getParent()
Answers the receiver's parent ThreadGroup.
|
void |
interrupt()
Interrupts every Thread in the receiver and recursively in all its subgroups.
|
boolean |
isDaemon()
Answers true if the receiver is a daemon ThreadGroup, false otherwise.
|
boolean |
isDestroyed()
Answers true if the receiver has been destroyed already, false otherwise.
|
void |
list()
Outputs to
System.out a text representation of the hierarchy of
Threads and ThreadGroups in the receiver (and recursively). |
boolean |
parentOf(ThreadGroup g)
Answers true if the receiver is a direct or indirect parent group of
ThreadGroup
g , false otherwise. |
void |
resume()
Deprecated.
Requires deprecated method Thread.resume().
|
void |
setDaemon(boolean isDaemon)
Configures the receiver to be a daemon ThreadGroup or not.
|
void |
setMaxPriority(int newMax)
Configures the maximum allowed priority for a Thread in the receiver
and recursively in all its subgroups.
|
void |
stop()
Deprecated.
Requires deprecated method Thread.stop().
|
void |
suspend()
Deprecated.
Requires deprecated method Thread.suspend().
|
String |
toString()
Answers a string containing a concise, human-readable
description of the receiver.
|
void |
uncaughtException(Thread t,
Throwable e)
Any uncaught exception in any Thread has to be forwarded (by the VM) to the Thread's ThreadGroup
by sending this message (uncaughtException).
|
public ThreadGroup(String name)
Thread.currentThread()
belongs.name
- Name for the ThreadGroup being createdSecurityException
- if checkAccess()
for the parent group fails with a SecurityExceptionThread.currentThread()
public ThreadGroup(ThreadGroup parent, String name)
parent
parent
- Parent ThreadGroupname
- Name for the ThreadGroup being createdNullPointerException
- if parent
is null
SecurityException
- if checkAccess()
for the parent group fails with a SecurityExceptionIllegalThreadStateException
- if parent
has been destroyed alreadypublic int activeCount()
public int activeGroupCount()
@Deprecated public boolean allowThreadSuspension(boolean b)
suspend()
.
The behavior of this call was never specified.b
- Used to control low memory implicit suspensionpublic final void checkAccess()
checkAccess
in it passing the receiver as parameter, otherwise do nothing.public final void destroy()
IllegalThreadStateException
- if the receiver or any of its subgroups has been destroyed alreadySecurityException
- if this.checkAccess()
fails with a SecurityExceptionpublic int enumerate(Thread[] threads)
threads
passed as parameters. If the array passed as parameter is too small no
exception is thrown - the extra elements are simply not copied.threads
- Thread array into which the Threads will be copiedpublic int enumerate(Thread[] threads, boolean recurse)
threads
passed as parameter. Children Threads of subgroups are recursively copied
as well if parameter recurse
is true
.
If the array passed as parameter is too small no
exception is thrown - the extra elements are simply not copied.threads
- array into which the Threads will be copiedrecurse
- Indicates whether Threads in subgroups should be recursively copied as well or notpublic int enumerate(ThreadGroup[] groups)
groups
passed as parameters. If the array passed as parameter is too small no
exception is thrown - the extra elements are simply not copied.groups
- array into which the ThreadGroups will be copiedpublic int enumerate(ThreadGroup[] groups, boolean recurse)
groups
passed as parameter. Children ThreadGroups of subgroups are recursively copied
as well if parameter recurse
is true
.
If the array passed as parameter is too small no
exception is thrown - the extra elements are simply not copied.groups
- array into which the ThreadGroups will be copiedrecurse
- Indicates whether ThreadGroups in subgroups should be recursively copied as well or notpublic final int getMaxPriority()
int
)setMaxPriority(int)
public final String getName()
public final ThreadGroup getParent()
public final void interrupt()
SecurityException
- if this.checkAccess()
fails with a SecurityExceptionThread.interrupt()
public final boolean isDaemon()
setDaemon(boolean)
,
destroy()
public boolean isDestroyed()
destroy()
public void list()
System.out
a text representation of the hierarchy of
Threads and ThreadGroups in the receiver (and recursively). Proper indentation
is done to suggest the nesting of groups inside groups and threads inside groups.public final boolean parentOf(ThreadGroup g)
g
, false otherwise.g
- ThreadGroup to test@Deprecated public final void resume()
SecurityException
- if this.checkAccess()
fails with a SecurityExceptionThread.resume()
,
suspend()
public final void setDaemon(boolean isDaemon)
isDaemon
- new value defining if receiver should be daemon or notSecurityException
- if checkAccess()
for the parent group fails with a SecurityExceptionisDaemon
,
destroy()
public final void setMaxPriority(int newMax)
newMax
- the new maximum priority to be setSecurityException
- if checkAccess()
fails with a SecurityExceptionIllegalArgumentException
- if the new priority is greater than Thread.MAX_PRIORITY or less than
Thread.MIN_PRIORITYgetMaxPriority()
@Deprecated public final void stop()
SecurityException
- if this.checkAccess()
fails with a SecurityExceptionThread.stop()
,
Thread.stop(Throwable)
,
ThreadDeath
@Deprecated public final void suspend()
SecurityException
- if this.checkAccess()
fails with a SecurityExceptionThread.suspend()
,
resume()
public String toString()
public void uncaughtException(Thread t, Throwable e)
uncaughtException
in interface Thread.UncaughtExceptionHandler
t
- Thread with an uncaught exceptione
- The uncaught exception itselfThread.stop()
,
Thread.stop(Throwable)
,
ThreadDeath
Eclipse OpenJ9 website.
To raise a bug report or suggest an improvement create an Eclipse OpenJ9 issue.
Copyright © 1993, 2025 IBM Corp. and others.