java.lang
public class ThreadGroup extends Object implements Thread.UncaughtExceptionHandler
Since: 1.0
See Also: Thread
UNKNOWN: updated to 1.4
Constructor Summary | |
---|---|
ThreadGroup(String name)
Create a new ThreadGroup using the given name and the current thread's
ThreadGroup as a parent. | |
ThreadGroup(ThreadGroup parent, String name)
Create a new ThreadGroup using the given name and parent group. |
Method Summary | |
---|---|
int | activeCount()
Return an estimate of the total number of active threads in this
ThreadGroup and all its descendants. |
int | activeGroupCount()
Get the number of active groups in this ThreadGroup. |
boolean | allowThreadSuspension(boolean allow)
Originally intended to tell the VM whether it may suspend Threads in
low memory situations, this method was never implemented by Sun, and
is hence a no-op.
|
void | checkAccess()
Find out if the current Thread can modify this ThreadGroup. |
void | destroy()
Destroy this ThreadGroup. |
int | enumerate(Thread[] array)
Copy all of the active Threads from this ThreadGroup and its descendants
into the specified array. |
int | enumerate(Thread[] array, boolean recurse)
Copy all of the active Threads from this ThreadGroup and, if desired,
from its descendants, into the specified array. |
int | enumerate(ThreadGroup[] array)
Copy all active ThreadGroups that are descendants of this ThreadGroup
into the specified array. |
int | enumerate(ThreadGroup[] array, boolean recurse)
Copy all active ThreadGroups that are children of this ThreadGroup into
the specified array, and if desired, also all descendents. |
int | getMaxPriority()
Get the maximum priority of Threads in this ThreadGroup. |
String | getName()
Get the name of this ThreadGroup.
|
ThreadGroup | getParent()
Get the parent of this ThreadGroup. |
void | interrupt()
Interrupt all Threads in this ThreadGroup and its sub-groups. |
boolean | isDaemon()
Tell whether this ThreadGroup is a daemon group. |
boolean | isDestroyed()
Tell whether this ThreadGroup has been destroyed or not.
|
void | list()
Print out information about this ThreadGroup to System.out. |
boolean | parentOf(ThreadGroup group)
Check whether this ThreadGroup is an ancestor of the specified
ThreadGroup, or if they are the same.
|
void | resume()
Resume all suspended Threads in this ThreadGroup and its descendants.
|
void | setDaemon(boolean daemon)
Set whether this ThreadGroup is a daemon group. |
void | setMaxPriority(int maxpri)
Set the maximum priority for Threads in this ThreadGroup. setMaxPriority
can only be used to reduce the current maximum. |
void | stop()
Stop all Threads in this ThreadGroup and its descendants.
|
void | suspend()
Suspend all Threads in this ThreadGroup and its descendants.
|
String | toString()
Return a human-readable String representing this ThreadGroup. |
void | uncaughtException(Thread thread, Throwable t)
When a Thread in this ThreadGroup does not catch an exception, the
virtual machine calls this method. |
checkAccess
.
Parameters: name the name to use for the ThreadGroup
Throws: SecurityException if the current thread cannot create a group
See Also: checkAccess
checkAccess
.
Parameters: name the name to use for the ThreadGroup parent the ThreadGroup to use as a parent
Throws: NullPointerException if parent is null SecurityException if the current thread cannot create a group IllegalThreadStateException if the parent is destroyed
See Also: checkAccess
Returns: count of active threads in this ThreadGroup and its descendants
Returns: the number of active groups in this ThreadGroup
Deprecated: pointless, since suspend is deprecated
Originally intended to tell the VM whether it may suspend Threads in low memory situations, this method was never implemented by Sun, and is hence a no-op.Parameters: allow whether to allow low-memory thread suspension; ignored
Returns: false
Since: 1.1
SecurityManager.checkAccess(this)
.
Throws: SecurityException if the current Thread cannot modify this ThreadGroup
See Also: checkAccess
checkAccess
.
Throws: IllegalThreadStateException if the ThreadGroup is not empty, or was previously destroyed SecurityException if permission is denied
See Also: checkAccess
checkAccess
.
Parameters: array the array to put the threads into
Returns: the number of threads put into the array
Throws: SecurityException if permission was denied NullPointerException if array is null ArrayStoreException if a thread does not fit in the array
See Also: activeCount checkAccess (Thread[], boolean)
checkAccess
.
Parameters: array the array to put the threads into recurse whether to recurse into descendent ThreadGroups
Returns: the number of threads put into the array
Throws: SecurityException if permission was denied NullPointerException if array is null ArrayStoreException if a thread does not fit in the array
See Also: activeCount checkAccess
checkAccess
.
Parameters: array the array to put the ThreadGroups into
Returns: the number of ThreadGroups copied into the array
Throws: SecurityException if permission was denied NullPointerException if array is null ArrayStoreException if a group does not fit in the array
See Also: activeCount checkAccess (ThreadGroup[], boolean)
checkAccess
.
Parameters: array the array to put the ThreadGroups into recurse whether to recurse into descendent ThreadGroups
Returns: the number of ThreadGroups copied into the array
Throws: SecurityException if permission was denied NullPointerException if array is null ArrayStoreException if a group does not fit in the array
See Also: activeCount checkAccess
Returns: the maximum priority of Threads in this ThreadGroup
Returns: the name of this ThreadGroup
checkAccess
.
Returns: the parent of this ThreadGroup
Throws: SecurityException if permission is denied
checkAccess
.
Throws: SecurityException if permission is denied
Since: 1.2
See Also: checkAccess interrupt
Returns: whether this ThreadGroup is a daemon group
Returns: whether this ThreadGroup has been destroyed or not
Since: 1.1
Parameters: group the group to test on
Returns: whether this ThreadGroup is a parent of the specified group
Deprecated: pointless, since suspend is deprecated
Resume all suspended Threads in this ThreadGroup and its descendants. To mirror suspend(), there is a security check:checkAccess()
, followed by further checks on each thread
being resumed.
Throws: SecurityException if permission is denied
See Also: checkAccess suspend
checkAccess
.
Parameters: daemon whether this ThreadGroup should be a daemon group
Throws: SecurityException if you cannot modify this ThreadGroup
See Also: checkAccess
checkAccess
.
Parameters: maxpri the new maximum priority for this ThreadGroup
Throws: SecurityException if you cannot modify this ThreadGroup
See Also: getMaxPriority checkAccess
Deprecated: unsafe operation, try not to use
Stop all Threads in this ThreadGroup and its descendants.This is inherently unsafe, as it can interrupt synchronized blocks and
leave data in bad states. Hence, there is a security check:
checkAccess()
, followed by further checks on each thread
being stopped.
Throws: SecurityException if permission is denied
See Also: checkAccess stop
Deprecated: unsafe operation, try not to use
Suspend all Threads in this ThreadGroup and its descendants.This is inherently unsafe, as suspended threads still hold locks,
which can lead to deadlock. Hence, there is a security check:
checkAccess()
, followed by further checks on each thread
being suspended.
Throws: SecurityException if permission is denied
See Also: checkAccess suspend
getClass().getName() + "[name=" + getName() + ",maxpri="
+ getMaxPriority() + ']'
.
Returns: a human-readable String representing this ThreadGroup
Parameters: thread the thread that exited t the uncaught throwable
Throws: NullPointerException if t is null
See Also: ThreadDeath err printStackTrace