THE Java™ Programming Language, Fourth Edition

(Jeff_L) #1
public final booleanisDaemon()

Returns the daemon status of this thread group.

public final voidsetMaxPriority(int maxPri)

Sets the maximum priority of this thread group.

public final intgetMaxPriority()

Gets the current maximum priority of this thread group.

public final booleanparentOf(ThreadGroup g)

Checks whether this thread group is a parent of the group g, or is the group
g. This might be better thought of as "part of," since a group is part of itself.

public final voidcheckAccess()

Throws SecurityException if the current thread is not allowed to
modify this group. Otherwise, this method simply returns.

public final voiddestroy()

Destroys this thread group. The thread group must contain no threads or this
method throws IllegalThreadStateException. If the group
contains other groups, they must also be empty of threads. This does not
destroy the threads in the group.

You can examine the contents of a thread group using two parallel sets of methods: One gets the threads
contained in the group, and the other gets the thread groups contained in the group.


public intactiveCount()

Returns an estimate of the number of active threads in this group, including
threads contained in all subgroups. This is an estimate because by the time
you get the number it may be out of date. Threads may have died, or new
ones may have been created, during or after the invocation of
activeCount. An active thread is one for which isAlive returns true.

public intenumerate(Thread[] threadsInGroup, boolean recurse)

Fills the threadsInGroup array with a reference to every active thread in
the group, up to the size of the array, and returns the number of threads
stored. If recurse is false, only threads directly in the group are
included; If it is TRue, all threads in the group's hierarchy will be included.
ThreadGroup.enumerate gives you control over whether you recurse,
but THReadGroup.activeCount does not. You can get a reasonable
estimate of the size of an array needed to hold the results of a recursive
enumeration, but you will overestimate the size needed for a non-recursive
enumerate.

public intenumerate(Thread[] threadsInGroup)
Free download pdf