public class Thread extends ObjectA
Threadis a concurrent unit of execution. It has its own call stack for methods being invoked, their arguments and local variables. Each virtual machine instance has at least one main
Threadrunning when it is started; typically, there are several others for housekeeping. The application might decide to launch additional
Threads for specific purposes.
Threads in the same VM interact and synchronize by the use of shared objects and monitors associated with these objects. Synchronized methods and part of the API in
Threads to cooperate.
There are basically two main ways of having a
Threadexecute application code. One is providing a new class that extends
Threadand overriding its
run()method. The other is providing a new
Threadinstance with a
Runnableobject during its creation. In both cases, the
#start()method must be called to actually execute the new
Threadhas an integer priority that basically determines the amount of CPU time the
Threadgets. It can be set using the
Threadcan also be made a daemon, which makes it run in the background. The latter also affects VM termination behavior: the VM does not terminate automatically as long as there are non-daemon threads running.
- See Also:
Constructors Constructor and Description
Thread()Constructs a new Thread with no runnable object and a newly generated name.
public Thread()Constructs a new Thread with no runnable object and a newly generated name. The new Thread will belong to the same ThreadGroup as the Thread calling this constructor.
- See Also: