ThreadGroup
object. ThreadGroup
object. ThreadGroup
object. ThreadGroup
object. millis
milliseconds for this threadgroup to die. millis
milliseconds plus nanos
nanoseconds for
this threadgroup to die. Runnable
run object,
then that Runnable
object's run
method is called; otherwise,
this method does nothing and returns. name
. run
method
of this threadgroup. public static final int MIN_PRIORITY
public static final int NORM_PRIORITY
public static final int MAX_PRIORITY
public ThreadGroup()
ThreadGroup
object. This constructor has the same effect as
ThreadGroup(null, null,
gname)
, where gname
is a newly generated name. Automatically generated names are of the form "ThreadGroup-"+
n,
where n is an integer. ThreadGroups created this way must have overridden their run()
method to actually do anything.
public ThreadGroup(Runnable target)
ThreadGroup
object. This constructor has the same effect as
ThreadGroup(null, target,
gname)
, where gname is a
newly generated name. Automatically generated names are of the form "ThreadGroup-"+
n,
where n is an integer. run
method is called. public ThreadGroup(String name)
ThreadGroup
object. This constructor has the same effect as
ThreadGroup(null, null, name)
. public ThreadGroup(Runnable target, String name)
ThreadGroup
object so that it has target
as
its run object, and has the specified name
as its name. If the target
argument is not null
, the run
method of the target
is called when this threadgroup is started. If the target argument is null
,
this threadgroup's run
method is called when this threadgroup is started.
The priority of the newly created threadgroup is set equal to the priority of the
threadgroup creating it, that is, the currently running threadgroup. The method setPriority
may be used to change the priority to a new value.
The newly created threadgroup is initially marked as being a daemon threadgroup if and
only if the threadgroup creating it is currently marked as a daemon threadgroup. The
method setDaemon
may be used to change whether or not a threadgroup is a
daemon.
run
method is called. public static native ThreadGroup myTeam()
public static native void yield()
public static native void sleep(long millis) throws InterruptedException
public static void sleep(long millis, int nanos) throws InterruptedException
public native synchronized void start()
run
method
of this threadgroup. The result is that two threadgroups are running concurrently: the
current threadgroup (which returns from the call to the start
method) and the
other threadgroup (which executes its run
method).
public void run()
Runnable
run object,
then that Runnable
object's run
method is called; otherwise,
this method does nothing and returns. Subclasses of ThreadGroup
should
override this method.
public final void stop()
The threadgroup represented by this
threadgroup is forced to stop whatever it is doing abnormally and to throw a newly created
ThreadDeath
object as an exception.
It is permitted to stop a threadgroup that has not yet been started. If the threadgroup is eventually started, it immediately terminates.
An application should not normally try to catch ThreadDeath
unless it must
do some extraordinary cleanup operation (note that the throwing of ThreadDeath
causes finally
clauses of try
statements to be executed before
the threadgroup officially dies). If a catch
clause catches a ThreadDeath
object, it is important to rethrow the object so that the threadgroup actually dies.
The top-level error handler that reacts to otherwise uncaught exceptions does not print
out a message or otherwise notify the application if the uncaught exception is an instance
of ThreadDeath
.
public final synchronized void stop(Throwable o)
If the argument obj
is null, a
NullPointerException
is thrown (in the current threadgroup).
The threadgroup represented by this threadgroup is forced to complete whatever it is
doing abnormally and to throw the Throwable
object obj
as an
exception. This is an unusual action to take; normally, the stop
method that
takes no arguments should be used.
It is permitted to stop a threadgroup that has not yet been started. If the threadgroup is eventually started, it immediately terminates.
public void interrupt()
public static boolean interrupted()
interrupted
is a static method, while isInterrupted
is called on the current ThreadGroup
instance. true
if the current threadgroup has been interrupted; false
otherwise. public boolean isInterrupted()
isInterrupted
is called on the current ThreadGroup
instance; by contrast, interrupted
is a static method. true
if this threadgroup has been interrupted; false
otherwise. public final native boolean isAlive()
true
if this threadgroup is alive; false
otherwise. public final void suspend()
If the threadgroup is alive, it is suspended and makes no further progress unless and until it is resumed.
public final void resume()
If the threadgroup is alive but suspended, it is resumed and is permitted to make progress in its execution.
public final void setPriority(int newPriority)
Otherwise, the priority of this threadgroup
is set to the smaller of the specified newPriority
and the maximum permitted
priority of the threadgroup's threadgroup group.
MIN_PRIORITY
to MAX_PRIORITY
.
public final int getPriority()
public final void setName(String name)
name
.
public final String getName()
public final synchronized void join(long millis) throws InterruptedException
millis
milliseconds for this threadgroup to die. A timeout of
0
means to wait forever. public final synchronized void join(long millis, int nanos) throws InterruptedException
millis
milliseconds plus nanos
nanoseconds for
this threadgroup to die. public final void join() throws InterruptedException
public final void setDaemon(boolean on)
This method must be called before the threadgroup is started.
true
, marks this threadgroup as a daemon threadgroup. public final boolean isDaemon()
true
if this threadgroup is a daemon threadgroup; false
otherwise. public String toString()