Threads of Control |
By now, you know are familiar with threads and you've seen a simple Java application that runs two threads concurrently. And you've had an opportunity to watch threads in action using the SystemMonitor applet. This page introduces you several features specific to Java threads and provides you with links to pages that talk about each feature in detail.Java threads are implemented by the Thread class which is part of the java.lang package. The Thread class implements a system independent definition of Java threads. But under the hood, the actual implementation of concurrent operation is provided by a system-specific implementation. For most programming needs, the underlying implementation doesn't matter; you can ignore the underlying implementation and program to the thread API described in this lesson and the other documentation provided with the Java system.
- Thread Body
- All of the action takes place in the thread's body--the thread's
run()
method. You can provide the body to a Thread in one of two ways: by subclassing the Thread class and overriding itsrun()
method, or creating a Thread with a Runnable object as its target.- Thread State
- Throughout its life, a Java thread is in one of several states. A thread's state indicates what the Thread is doing and what it is capable of doing at that time of its life: is it running? is it sleeping? is it dead?
- Thread Priority
- A thread's priority indicates to the Java thread scheduler when this thread should run in relation to all of the other threads.
- Daemon Threads
- Daemon threads are those that provide a service for other threads in the system. Any Java thread can be a daemon thread.
- Thread Group
- All threads belong to a thread group. ThreadGroup, a java.lang class, defines and implements the capabilities of a group of related threads.
Threads of Control |