ThreadGroup
ThreadGroupcreates a group of threads. It defines these two constructors:
ThreadGroup(StringgroupName)
ThreadGroup(ThreadGroupparentOb, StringgroupName)
424 Part II: The Java Library
Method Description
final boolean isAlive( ) Returnstrueif the thread is still active. Other wise,
it returnsfalse.
final boolean isDaemon( ) Returnstrueif the thread is a daemon thread.
Other wise, it returnsfalse.
boolean isInterrupted( ) Returnstrueif the thread is interrupted.
Other wise, it returnsfalse.
final void join( )
throws InterruptedException
Waits until the thread terminates.
final void join(longmilliseconds)
throws InterruptedException
Waits up to the specified number of milliseconds
for the thread on which it is called to terminate.
final void join(longmilliseconds,
intnanoseconds)
throws InterruptedException
Waits up to the specified number of milliseconds
plus nanoseconds for the thread on which it is
called to terminate.
void run( ) Begins execution of a thread.
void setContextClassLoader(ClassLoadercl) Sets the class loader that will be used by the
invoking thread tocl.
final void setDaemon(booleanstate) Flags the thread as a daemon thread.
static void
setDefaultUncaughtExceptionHandler(
Thread.UncaughtExceptionHandlere)
Sets the default uncaught exception handler toe.
final void setName(StringthreadName) Sets the name of the thread to that specified by
threadName.
final void setPriority(intpriority) Sets the priority of the thread to that specified by
priority.
void
setUncaughtExceptionHandler(
Thread.UncaughtExceptionHandlere)
Sets the invoking thread’s default uncaught
exception handler toe.
static void sleep(longmilliseconds)
throws InterruptedException
Suspends execution of the thread for the specified
number of milliseconds.
static void sleep(longmilliseconds,
intnanoseconds)
throws InterruptedException
Suspends execution of the thread for the specified
number of milliseconds plus nanoseconds.
void start( ) Starts execution of the thread.
String toString( ) Returns the string equivalent of a thread.
static void yield( ) The calling thread yields the CPU to another thread.
TABLE 16-17 The Methods Defined byThread(continued)