java.lang.Object | +--java.lang.ThreadGroup
ThreadGroup(java.lang.String name) Create a new ThreadGroup using the given name and the current thread's ThreadGroup as a parent. |
ThreadGroup(java.lang.ThreadGroup parent, java.lang.String name) Create a new ThreadGroup using the given name and parent group. |
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. |
synchronized void | destroy() Destroy this ThreadGroup. |
int | enumerate(java.lang.Thread array) Copy all of the active Threads from this ThreadGroup and its descendants into the specified array. |
int | enumerate(java.lang.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(java.lang.ThreadGroup array) Copy all active ThreadGroups that are descendants of this ThreadGroup into the specified array. |
int | enumerate(java.lang.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. |
java.lang.String | getName() Get the name of this ThreadGroup. |
java.lang.ThreadGroup | getParent() Get the parent of this ThreadGroup. |
synchronized void | interrupt() Interrupt all Threads in this ThreadGroup and its sub-groups. |
boolean | isDaemon() Tell whether this ThreadGroup is a daemon group. |
synchronized boolean | isDestroyed() Tell whether this ThreadGroup has been destroyed or not. |
void | list() Print out information about this ThreadGroup to System.out. |
boolean | parentOf(java.lang.ThreadGroup tg) Check whether this ThreadGroup is an ancestor of the specified ThreadGroup, or if they are the same. |
synchronized void | resume() Resume all suspended Threads in this ThreadGroup and its descendants. |
void | setDaemon(boolean daemon) Set whether this ThreadGroup is a daemon group. |
synchronized void | setMaxPriority(int maxpri) Set the maximum priority for Threads in this ThreadGroup. |
synchronized void | stop() Stop all Threads in this ThreadGroup and its descendants. |
synchronized void | suspend() Suspend all Threads in this ThreadGroup and its descendants. |
java.lang.String | toString() Return a human-readable String representing this ThreadGroup. |
void | uncaughtException(java.lang.Thread thread, java.lang.Throwable t) When a Thread in this ThreadGroup does not catch an exception, the virtual machine calls this method. |
public ThreadGroup(java.lang.String name)
checkAccess
.
name
- the name to use for the ThreadGroupSecurityException
- if the current thread cannot create a grouppublic ThreadGroup(java.lang.ThreadGroup parent, java.lang.String name)
checkAccess
.
parent
- the name to use for the ThreadGroupname
- the ThreadGroup to use as a parentNullPointerException
- if parent is nullSecurityException
- if the current thread cannot create a groupIllegalThreadStateException
- if the parent is destroyedpublic int activeCount()
public int activeGroupCount()
public boolean allowThreadSuspension(boolean allow)
allow
- whether to allow low-memory thread suspension; ignoredpublic final void checkAccess()
SecurityManager.checkAccess(this)
.
SecurityException
- if the current Thread cannot modify this
ThreadGrouppublic final synchronized void destroy()
checkAccess
.
IllegalThreadStateException
- if the ThreadGroup is not empty, or
was previously destroyedSecurityException
- if permission is deniedpublic int enumerate(java.lang.Thread array)
checkAccess
.
array
- the array to put the threads intoSecurityException
- if permission was deniedNullPointerException
- if array is nullArrayStoreException
- if a thread does not fit in the arraypublic int enumerate(java.lang.Thread array, boolean recurse)
checkAccess
.
array
- the array to put the threads intorecurse
- whether to recurse into descendent ThreadGroupsSecurityException
- if permission was deniedNullPointerException
- if array is nullArrayStoreException
- if a thread does not fit in the arraypublic int enumerate(java.lang.ThreadGroup array)
checkAccess
.
array
- the array to put the ThreadGroups intoSecurityException
- if permission was deniedNullPointerException
- if array is nullArrayStoreException
- if a group does not fit in the arraypublic int enumerate(java.lang.ThreadGroup array, boolean recurse)
checkAccess
.
array
- the array to put the ThreadGroups intorecurse
- whether to recurse into descendent ThreadGroupsSecurityException
- if permission was deniedNullPointerException
- if array is nullArrayStoreException
- if a group does not fit in the arraypublic final int getMaxPriority()
public final String getName()
public final ThreadGroup getParent()
checkAccess
.
SecurityException
- if permission is deniedpublic final synchronized void interrupt()
checkAccess
.
SecurityException
- if permission is deniedpublic final boolean isDaemon()
public synchronized boolean isDestroyed()
public void list()
public final boolean parentOf(java.lang.ThreadGroup tg)
tg
- the group to test onpublic final synchronized void resume()
checkAccess()
, followed by further checks on each thread
being resumed.
SecurityException
- if permission is deniedpublic final void setDaemon(boolean daemon)
checkAccess
.
daemon
- whether this ThreadGroup should be a daemon groupSecurityException
- if you cannot modify this ThreadGrouppublic final synchronized void setMaxPriority(int maxpri)
checkAccess
.
maxpri
- the new maximum priority for this ThreadGroupSecurityException
- if you cannot modify this ThreadGrouppublic final synchronized void stop()
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.
SecurityException
- if permission is deniedpublic final synchronized void suspend()
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.
SecurityException
- if permission is deniedpublic String toString()
getClass().getName() + "[name=" + getName() + ",maxpri="
+ getMaxPriority() + ']'
.
public void uncaughtException(java.lang.Thread thread, java.lang.Throwable t)
thread
- the thread that exitedt
- the uncaught exceptionNullPointerException
- if t is null