14.3. The Thread
Class¶
14.3.1. java.lang.Thread
¶
In Java, a thread is represented using an object of the Thread class, which encapsulates:
the method that the thread’s instructions come from (i.e., its run() method);
the name of thread (see getName());
its high-level state of execution (see getState());
whether or not the program must wait for the thread to terminate in order for the program itself to terminate (see isDaemon());
and other pieces of high-level and low-level information, some of which may not be publicly available (e.g., the next instruction the thread will emit).
A Thread
object typically gets its own area in memory for the
work performed by its run()
method; however, the details of how
that memory is managed is outside the scope of this chapter.