Noticing Brief Changes in Value Using TransitionDetector

Appendix B - The ThreadGroup API

Java Thread Programming
Paul Hyde
  Copyright 1999 Sams Publishing

Instance Methods
There are no static methods on ThreadGroup ; all the methods are instance methods.
activeCount()
public int activeCount()
Returns the number of active threads in this thread group and all its subgroups. Related method: enumerate() . See Chapter 10 for more information.
activeGroupCount()
public int activeGroupCount()
Returns the number of active thread groups in this thread group and all its subgroups.
checkAccess()
public final void checkAccess() throws SecurityException
Checks to see if there is a SecurityManager and if it will allow the current thread to access this ThreadGroup . Throws a SecurityException if the current thread is denied access. Many other methods of ThreadGroup invoke checkAccess() internally.
destroy()
public final void destroy()
        throws SecurityException, IllegalThreadStateException
Destroys this thread group and all its subgroups. If any of the groups is not empty (meaning that all the threads within have not died), an IllegalThreadStateException will be thrown. It throws a SecurityException if the current thread is denied access to this thread group.
enumerate(Thread[ ], boolean)
public int enumerate(Thread[] dest, boolean includeSubgroups)
        throws SecurityException
Collects a reference to all the threads in this thread group (and recursively all its subgroups if includeSubgroups is true ) and copies these Thread references into dest . A SecurityException can be thrown if the operation is not allowed by checkAccess() . The number of references copied into dest is returned. If dest is too small, the extra Thread references are quietly thrown away. The activeCount() method can be used to estimate the size needed for the dest array. In general, dest should be about twice the size you think youll need to be sure that all the threads get copied into it. Related methods: activeCount() , enumerate(Thread[ ]) . See Chapter 10 for more information.
enumerate(Thread[ ])
public int enumerate(Thread[] dest) throws SecurityException
Equivalent to: enumerate(dest, true) .
enumerate(ThreadGroup[ ], boolean)
public int enumerate(ThreadGroup[] dest, boolean includeSubgroups)
        throws SecurityException
Collects a reference to all the thread groups in this thread group (and recursively all its subgroups if includeSubgroups is true ) and copies these ThreadGroup references into dest . A SecurityException can be thrown if the operation is not allowed by checkAccess() . The number of references copied into dest is returned. If dest is too small, the extra ThreadGroup references are quietly thrown away. The activeGroupCount() method can be used to estimate the size needed for the dest array. In general, dest should be about twice the size you think youll need to be sure that all the thread groups get copied into it. Related methods: activeGroupCount() , enumerate(ThreadGroup[]) .
enumerate(ThreadGroup[ ])
public int enumerate(ThreadGroup[] dest) throws SecurityException
Equivalent to: enumerate(dest, true) .
getMaxPriority()
public final int getMaxPriority()
Returns the maximum priority that any thread in this group or one of its subgroups can have. Related method: setMaxPriority() . See Chapters 6 and 10 for more information.
getName()
public final String getName()
Returns the name of this thread group. See Chapter 10 for more information.
getParent()
public final ThreadGroup getParent() throws SecurityException
Returns the parent thread group of this thread group, or null if this thread group does not have a parent (top thread group). A SecurityException can be thrown if the parent is not null and its checkAccess() method disapproves. See Chapter 10 for more information.
interrupt()
public final void interrupt() throws SecurityException
Interrupts all the threads in this thread group and all its subgroups. A SecurityException can be thrown if any of the threads or thread groups disapprove. See Chapter 5 for more information.
isDaemon()
public final boolean isDaemon()
Returns true if this thread group is a daemon thread group, false otherwise . A daemon thread group is automatically destroyed when the last of its threads dies. Related method: setDaemon() .
isDestroyed()
public synchronized boolean isDestroyed()
Returns true if this thread group has been destroyed, false otherwise. Related method: destroy() .
list()
public void list()
Dumps information about all the threads in this thread group and all its subgroups to System.out by invoking toString() on each Thread . Really only useful for debugging.
parentOf(ThreadGroup)
public final boolean parentOf(ThreadGroup group)
Returns true if this thread group is an ancestor of group , false otherwise. Related method: getParent() .
setDaemon(boolean)
public final void setDaemon(boolean newStatus)
        throws SecurityException
If newStatus is true , this thread group will be automatically destroyed when all its threads have died. Otherwise, if newStatus is false , it will be a normal thread group. A SecurityException will be thrown if the current thread does not have permission to modify this thread group. Related method: isDaemon() .
setMaxPriority(int)
public final void setMaxPriority(int newMax) throws SecurityException
Sets the maximum priority that a thread in this thread group (and all its subgroups) can have. Threads already running at a priority higher than this are not affected. A SecurityException will be thrown if the current thread does not have permission to modify this thread group. Related method: getMaxPriority() .
toString()
public String toString()
Returns a string representation of this thread group including its name and maximum thread priority.
uncaughtException(Thread, Throwable)
public void uncaughtException(Thread deadThread, Throwable exception)
The Java VM calls this method when a thread in this thread group throws an Exception or Error that is not caught inside run() . The thread that did not catch the exception is deadThread , and the Throwable that it did not catch is exception . This method can be over-ridden in a subclass of ThreadGroup to intercept this information. If it is not overridden, the default behavior is for it to invoke the uncaughtException() method of this groups parent group. If this group does not have a parent and the Throwable is anything other than an instance of ThreadDeath , a stack trace is printed to System.err .

Toc


Java Thread Programming
Java Thread Programming
ISBN: 0672315858
EAN: 2147483647
Year: 2005
Pages: 149
Authors: Paul Hyde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net