|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.ThreadGroup
public class ThreadGroup
A ThreadGroup is a means of organizing Threads into a
hierarchical structure. A ThreadGroup can contain zero or more
Threads and zero or more other ThreadGroups. Each Thread and each ThreadGroup (except the root group) has a unique
parent ThreadGroup. The result is a tree whose inner nodes are
ThreadGroups and whose leaf nodes are Threads. The unique
root of the tree is a ThreadGroup that is created at VM startup and
has the name "system". The benefit of using ThreadGroups, in addition
to the mere housekeeping aspect, is that all Threads in a ThreadGroup can be manipulated together, that is, the ThreadGroup
has methods that delegate to all its all Threads.
Thread,
SecurityManager| Field Summary | |
|---|---|
(package private) static ThreadGroup |
mMain
|
(package private) static ThreadGroup |
mSystem
|
(package private) int |
numGroups
|
(package private) int |
numThreads
|
(package private) ThreadGroup |
parent
|
| Constructor Summary | |
|---|---|
ThreadGroup()
Initialize the special "system" ThreadGroup. |
|
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. |
|
| Method Summary | |
|---|---|
int |
activeCount()
Returns the number of Threads which are children of the receiver, directly or indirectly and are running. |
int |
activeGroupCount()
Returns the number of ThreadGroups which are children of the receiver, directly or indirectly. |
(package private) void |
add(Thread thread)
Adds a Thread to the receiver. |
(package private) void |
addThread(Thread thread)
Non-standard method for adding a thread to a group, required by Dalvik. |
boolean |
allowThreadSuspension(boolean b)
Deprecated. Required deprecated method suspend(). |
void |
checkAccess()
Checks the accessibility of the ThreadGroup from the perspective of the caller. |
void |
destroy()
Destroys the receiver and recursively all its subgroups. |
int |
enumerate(Thread[] threads)
Iterates over all active threads in this group (and its sub-groups) and stores the threads in the given array. |
int |
enumerate(Thread[] threads,
boolean recurse)
Iterates over all active threads in this group (and, optionally, its sub-groups) and stores the threads in the given array. |
int |
enumerate(ThreadGroup[] groups)
Iterates over all thread groups in this group (and its sub-groups) and and stores the groups in the given array. |
int |
enumerate(ThreadGroup[] groups,
boolean recurse)
Iterates over all thread groups in this group (and, optionally, its sub-groups) and and stores the groups in the given array. |
int |
getMaxPriority()
Returns the maximum allowed priority for a Thread in the receiver. |
String |
getName()
Returns the name of the receiver. |
ThreadGroup |
getParent()
Returns the receiver's parent ThreadGroup. |
void |
interrupt()
Interrupts every Thread in the receiver and recursively in all its subgroups. |
boolean |
isDaemon()
Checks whether the receiver is a daemon ThreadGroup. |
boolean |
isDestroyed()
Checks whether the receiver has already been destroyed. |
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)
Checks whether the receiver is a direct or indirect parent group of a given ThreadGroup. |
(package private) void |
remove(Thread thread)
Removes a Thread from the receiver. |
(package private) void |
removeThread(Thread thread)
Non-standard method for adding a thread to a group, required by Dalvik. |
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()
Returns a string containing a concise, human-readable description of the receiver. |
void |
uncaughtException(Thread t,
Throwable e)
Handles uncaught exceptions. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
ThreadGroup parent
int numThreads
int numGroups
static ThreadGroup mSystem
static ThreadGroup mMain
| Constructor Detail |
|---|
public ThreadGroup(String name)
Thread.currentThread() belongs.
name - the name for the ThreadGroup being created
SecurityException - if checkAccess() for the parent
group fails with a SecurityExceptionThread.currentThread()
public ThreadGroup(ThreadGroup parent,
String name)
parent.
parent - the parent ThreadGroupname - the name for the ThreadGroup being created
NullPointerException - if parent is
null
SecurityException - if checkAccess() for the parent
group fails with a SecurityException
IllegalThreadStateException - if parent has been
destroyed alreadyThreadGroup()
| Method Detail |
|---|
public int activeCount()
public int activeGroupCount()
final void add(Thread thread)
throws IllegalThreadStateException
thread - Thread to add to the receiver
IllegalThreadStateException - if the receiver has been destroyed
alreadyremove(java.lang.Thread)@Deprecated public boolean allowThreadSuspension(boolean b)
suspend(). The exact behavior of this call was never
specified.
b - Used to control low memory implicit suspension
true (always)public final void checkAccess()
checkAccess with the receiver as a parameter, otherwise does
nothing.
public final void destroy()
IllegalThreadStateException - if the receiver or any of its
subgroups has been destroyed already or if it still contains
threads.
SecurityException - if this.checkAccess() fails with
a SecurityExceptionpublic int enumerate(Thread[] threads)
threads - the array into which the Threads will be copied
public int enumerate(Thread[] threads,
boolean recurse)
threads - the array into which the Threads will be copiedrecurse - indicates whether Threads in subgroups should be
recursively copied as well
public int enumerate(ThreadGroup[] groups)
groups - the array into which the ThreadGroups will be copied
public int enumerate(ThreadGroup[] groups,
boolean recurse)
groups - the array into which the ThreadGroups will be copiedrecurse - indicates whether ThreadGroups in subgroups should be
recursively copied as well or not
public final int getMaxPriority()
setMaxPriority(int)public final String getName()
public final ThreadGroup getParent()
null if the
receiver is the the root ThreadGroup.
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 - the potential child ThreadGroup
gfinal void remove(Thread thread)
thread - Thread to remove from the receiveradd(Thread)@Deprecated public final void resume()
SecurityException - if this.checkAccess() fails with
a SecurityExceptionThread.resume(),
suspend()public final void setDaemon(boolean isDaemon)
isDaemon - the new value defining if receiver should be daemon or
not
SecurityException - if checkAccess() for the parent
group fails with a SecurityExceptionisDaemon,
destroy()public final void setMaxPriority(int newMax)
newMax - the new maximum priority to be set
SecurityException - if checkAccess() fails with a
SecurityException
IllegalArgumentException - 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()
toString in class Object
public void uncaughtException(Thread t,
Throwable e)
uncaughtException in interface Thread.UncaughtExceptionHandlert - the Thread that terminated with an uncaught exceptione - the uncaught exception itselfThread.stop(),
Thread.stop(Throwable),
ThreadDeath
void addThread(Thread thread)
throws IllegalThreadStateException
thread - Thread to add to the receiver
IllegalThreadStateException - if the receiver has been destroyed
alreadyadd(java.lang.Thread),
removeThread(java.lang.Thread)
void removeThread(Thread thread)
throws IllegalThreadStateException
thread - Thread to add to the receiver
IllegalThreadStateException - if the receiver has been destroyed
alreadyremove(java.lang.Thread),
addThread(java.lang.Thread)
|
Build 1.1_r1 (from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||