| java.lang.Object java.lang.ThreadGroup
All known Subclasses: sun.applet.AppletThreadGroup,
ThreadGroup | public class ThreadGroup (Code) | | A thread group represents a set of threads. In addition, a thread
group can also include other thread groups. The thread groups form
a tree in which every thread group except the initial thread group
has a parent.
A thread is allowed to access information about its own thread
group, but not to access information about its thread group's
parent thread group or any other thread groups.
author: unascribed version: 1.55 07/27/01 since: JDK1.0 |
Method Summary | |
public int | activeCount() Returns an estimate of the number of active threads in this
thread group. | public int | activeGroupCount() Returns an estimate of the number of active groups in this
thread group. | void | add(Thread t) Adds the specified Thread to this group. | void | addUnstarted() Increments the count of unstarted threads in the thread group. | final public void | checkAccess() Determines if the currently running thread has permission to
modify this thread group. | final public void | destroy() Destroys this thread group and all of its subgroups. | public int | enumerate(Thread list) Copies into the specified array every active thread in this
thread group and its subgroups. | public int | enumerate(Thread list, boolean recurse) Copies into the specified array every active thread in this
thread group. | public int | enumerate(ThreadGroup list) Copies into the specified array references to every active
subgroup in this thread group. | public int | enumerate(ThreadGroup list, boolean recurse) Copies into the specified array references to every active
subgroup in this thread group. | final public int | getMaxPriority() Returns the maximum priority of this thread group. | final public String | getName() Returns the name of this thread group. | final public ThreadGroup | getParent() Returns the parent of this thread group.
First, if the parent is not null , the
checkAccess method of the parent thread group is
called with no arguments; this may result in a security exception. | final public void | interrupt() Interrupts all threads in this thread group.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception. | final public boolean | isDaemon() Tests if this thread group is a daemon thread group. | public synchronized boolean | isDestroyed() Tests if this thread group has been destroyed. | public void | list() Prints information about this thread group to the standard
output. | void | list(PrintStream out, int indent) | final public boolean | parentOf(ThreadGroup g) Tests if this thread group is either the thread group
argument or one of its ancestor thread groups. | void | remove(Thread t) Removes the specified Thread from this group. | final public void | setDaemon(boolean daemon) Changes the daemon status of this thread group.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception. | final public void | setMaxPriority(int pri) Sets the maximum priority of the group. | public String | toString() Returns a string representation of this Thread group. | public void | uncaughtException(Thread t, Throwable e) Called by the Java Virtual Machine when a thread in this
thread group stops because of an uncaught exception. |
destroyed | boolean destroyed(Code) | | |
maxPriority | int maxPriority(Code) | | |
nUnstartedThreads | int nUnstartedThreads(Code) | | |
vmAllowSuspension | boolean vmAllowSuspension(Code) | | |
ThreadGroup | ThreadGroup()(Code) | | Creates an empty Thread group that is not in any Thread group.
This method is used to create the system Thread group.
|
ThreadGroup | public ThreadGroup(String name)(Code) | | Constructs a new thread group. The parent of this new group is
the thread group of the currently running thread.
The checkAccess method of the parent thread group is
called with no arguments; this may result in a security exception.
Parameters: name - the name of the new thread group. exception: SecurityException - if the current thread cannot create athread in the specified thread group. See Also: java.lang.ThreadGroup.checkAccess since: JDK1.0 |
ThreadGroup | public ThreadGroup(ThreadGroup parent, String name)(Code) | | Creates a new thread group. The parent of this new group is the
specified thread group.
The checkAccess method of the parent thread group is
called with no arguments; this may result in a security exception.
Parameters: parent - the parent thread group. Parameters: name - the name of the new thread group. exception: NullPointerException - if the thread group argument isnull . exception: SecurityException - if the current thread cannot create athread in the specified thread group. See Also: java.lang.SecurityException See Also: java.lang.ThreadGroup.checkAccess since: JDK1.0 |
activeCount | public int activeCount()(Code) | | Returns an estimate of the number of active threads in this
thread group.
the number of active threads in this thread group and in anyother thread group that has this thread group as an ancestor. since: JDK1.0 |
activeGroupCount | public int activeGroupCount()(Code) | | Returns an estimate of the number of active groups in this
thread group.
the number of active thread groups with this thread group asan ancestor. since: JDK1.0 |
addUnstarted | void addUnstarted()(Code) | | Increments the count of unstarted threads in the thread group.
Unstarted threads are not added to the thread group so that they
can be collected if they are never started, but they must be
counted so that daemon thread groups with unstarted threads in
them are not destroyed.
|
checkAccess | final public void checkAccess()(Code) | | Determines if the currently running thread has permission to
modify this thread group.
If there is a security manager, its checkAccess method
is called with this thread group as its argument. This may result
in throwing a SecurityException .
exception: SecurityException - if the current thread is not allowed toaccess this thread group. See Also: java.lang.SecurityManager.checkAccess(java.lang.ThreadGroup) since: JDK1.0 |
destroy | final public void destroy()(Code) | | Destroys this thread group and all of its subgroups. This thread
group must be empty, indicating that all threads that had been in
this thread group have since stopped.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception.
exception: IllegalThreadStateException - if the thread group is notempty or if the thread group has already been destroyed. exception: SecurityException - if the current thread cannot modify thisthread group. See Also: java.lang.ThreadGroup.checkAccess since: JDK1.0 |
enumerate | public int enumerate(Thread list)(Code) | | Copies into the specified array every active thread in this
thread group and its subgroups.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception.
An application should use the activeCount method to
get an estimate of how big the array should be. If the array is
too short to hold all the threads, the extra threads are silently
ignored.
Parameters: list - an array into which to place the list of threads. the number of threads put into the array. exception: SecurityException - if the current thread does nothave permission to enumerate this thread group. See Also: java.lang.ThreadGroup.activeCount See Also: java.lang.ThreadGroup.checkAccess since: JDK1.0 |
enumerate | public int enumerate(Thread list, boolean recurse)(Code) | | Copies into the specified array every active thread in this
thread group. If the recurse flag is
true , references to every active thread in this
thread's subgroups are also included. If the array is too short to
hold all the threads, the extra threads are silently ignored.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception.
An application should use the activeCount method to
get an estimate of how big the array should be.
Parameters: list - an array into which to place the list of threads. Parameters: recurse - a flag indicating whether also to include threadsin thread groups that are subgroups of thisthread group. the number of threads placed into the array. exception: SecurityException - if the current thread does nothave permission to enumerate this thread group. See Also: java.lang.ThreadGroup.activeCount See Also: java.lang.ThreadGroup.checkAccess since: JDK1.0 |
enumerate | public int enumerate(ThreadGroup list)(Code) | | Copies into the specified array references to every active
subgroup in this thread group.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception.
An application should use the activeGroupCount
method to get an estimate of how big the array should be. If the
array is too short to hold all the thread groups, the extra thread
groups are silently ignored.
Parameters: list - an array into which to place the list of thread groups. the number of thread groups put into the array. exception: SecurityException - if the current thread does nothave permission to enumerate this thread group. See Also: java.lang.ThreadGroup.activeGroupCount See Also: java.lang.ThreadGroup.checkAccess since: JDK1.0 |
enumerate | public int enumerate(ThreadGroup list, boolean recurse)(Code) | | Copies into the specified array references to every active
subgroup in this thread group. If the recurse flag is
true , references to all active subgroups of the
subgroups and so forth are also included.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception.
An application should use the activeGroupCount
method to get an estimate of how big the array should be.
Parameters: list - an array into which to place the list of threads. Parameters: recurse - a flag indicating whether to recursively enumerateall included thread groups. the number of thread groups put into the array. exception: SecurityException - if the current thread does nothave permission to enumerate this thread group. See Also: java.lang.ThreadGroup.activeGroupCount See Also: java.lang.ThreadGroup.checkAccess since: JDK1.0 |
getMaxPriority | final public int getMaxPriority()(Code) | | Returns the maximum priority of this thread group. Threads that are
part of this group cannot have a higher priority than the maximum
priority.
the maximum priority that a thread in this thread groupcan have. See Also: ThreadGroup.setMaxPriority since: JDK1.0 |
getName | final public String getName()(Code) | | Returns the name of this thread group.
the name of this thread group. since: JDK1.0 |
interrupt | final public void interrupt()(Code) | | Interrupts all threads in this thread group.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception.
This method then calls the interrupt method on all the
threads in this thread group and in all of its subgroups.
exception: SecurityException - if the current thread is not allowedto access this thread group or any of the threads inthe thread group. See Also: java.lang.Thread.interrupt See Also: java.lang.SecurityException See Also: java.lang.ThreadGroup.checkAccess since: 1.2 |
isDaemon | final public boolean isDaemon()(Code) | | Tests if this thread group is a daemon thread group. A
daemon thread group is automatically destroyed when its last
thread is stopped or its last thread group is destroyed.
true if this thread group is a daemon thread group;false otherwise. since: JDK1.0 |
isDestroyed | public synchronized boolean isDestroyed()(Code) | | Tests if this thread group has been destroyed.
true if this object is destroyed since: JDK1.1 |
list | public void list()(Code) | | Prints information about this thread group to the standard
output. This method is useful only for debugging.
since: JDK1.0 |
parentOf | final public boolean parentOf(ThreadGroup g)(Code) | | Tests if this thread group is either the thread group
argument or one of its ancestor thread groups.
Parameters: g - a thread group. true if this thread group is the thread groupargument or one of its ancestor thread groups;false otherwise. since: JDK1.0 |
remove | void remove(Thread t)(Code) | | Removes the specified Thread from this group.
Parameters: t - the Thread to be removed if the Thread has already been destroyed. |
setDaemon | final public void setDaemon(boolean daemon)(Code) | | Changes the daemon status of this thread group.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception.
A daemon thread group is automatically destroyed when its last
thread is stopped or its last thread group is destroyed.
Parameters: daemon - if true , marks this thread group asa daemon thread group; otherwise, marks thisthread group as normal. exception: SecurityException - if the current thread cannot modifythis thread group. See Also: java.lang.SecurityException See Also: java.lang.ThreadGroup.checkAccess since: JDK1.0 |
setMaxPriority | final public void setMaxPriority(int pri)(Code) | | Sets the maximum priority of the group. Threads in the thread
group that already have a higher priority are not affected.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception.
If the pri argument is less than
Thread.MIN_PRIORITY or greater than
Thread.MAX_PRIORITY , the maximum priority of the group
remains unchanged.
Otherwise, the priority of this ThreadGroup object is set to the
smaller of the specified pri and the maximum permitted
priority of the parent of this thread group. (If this thread group
is the system thread group, which has no parent, then its maximum
priority is simply set to pri .) Then this method is
called recursively, with pri as its argument, for
every thread group that belongs to this thread group.
Parameters: pri - the new priority of the thread group. exception: SecurityException - if the current thread cannot modifythis thread group. See Also: ThreadGroup.getMaxPriority See Also: java.lang.SecurityException See Also: java.lang.ThreadGroup.checkAccess since: JDK1.0 |
toString | public String toString()(Code) | | Returns a string representation of this Thread group.
a string representation of this thread group. since: JDK1.0 |
uncaughtException | public void uncaughtException(Thread t, Throwable e)(Code) | | Called by the Java Virtual Machine when a thread in this
thread group stops because of an uncaught exception.
The uncaughtException method of
ThreadGroup does the following:
- If this thread group has a parent thread group, the
uncaughtException method of that parent is called
with the same two arguments.
- Otherwise, this method determines if the
Throwable
argument is an instance of ThreadDeath . If so, nothing
special is done. Otherwise, the Throwable 's
printStackTrace method is called to print a stack
backtrace to the standard error stream.
Applications can override this method in subclasses of
ThreadGroup to provide alternative handling of
uncaught exceptions.
Parameters: t - the thread that is about to exit. Parameters: e - the uncaught exception. See Also: java.lang.System.err See Also: java.lang.ThreadDeath See Also: java.lang.Throwable.printStackTrace(java.io.PrintStream) since: JDK1.0 |
|
|