422 Part II: The Java Library
StrictMath
TheStrictMathclass defines a complete set of mathematical methods that parallel those
inMath. The difference is that theStrictMathversion is guaranteed to generate precisely
identical results across all Java implementations, whereas the methods inMathare given
more latitude in order to improve performance.
Compiler
TheCompilerclass supports the creation of Java environments in which Java bytecode is
compiled into executable code rather than interpreted. It is not for normal programming use.
Thread, ThreadGroup, and Runnable
TheRunnableinterface and theThreadandThreadGroupclasses support multithreaded
programming. Each is examined next.
NOTEOTE An overview of the techniques used to manage threads, implement theRunnableinterface,
and create multithreaded programs is presented in Chapter 11.
The Runnable Interface
TheRunnableinterface must be implemented by any class that will initiate a separate thread
of execution.Runnableonly defines one abstract method, calledrun( ), which is the entry
point tothe thread. It is defined like this:
void run( )
Threads that you create must implement this method.
Thread
Threadcreates a new thread of execution. It defines the following commonly used constructors:
Thread( )
Thread(RunnablethreadOb)
Thread(RunnablethreadOb, StringthreadName)
Thread(StringthreadName)
Thread(ThreadGroupgroupOb, RunnablethreadOb)
Thread(ThreadGroupgroupOb, RunnablethreadOb, StringthreadName)
Thread(ThreadGroupgroupOb, StringthreadName)
threadObis an instance of a class that implements theRunnableinterface and defines where
execution of the thread will begin. The name of the thread is specified bythreadName.When a
name is not specified, one is created by theJava Virtual Machine.groupObspecifies the thread
group to which the new thread will belong. When no thread group is specified, the new thread
belongs to the same group as the parent thread.
The following constants are defined byThread:
MAX_PRIORITY
MIN_PRIORITY
NORM_PRIORITY