Runnable
Name
RunnableSynopsis
- Interface Name:
java.lang.Runnable
- Super-interface:
- None
- Immediate Sub-interfaces:
- None
- Implemented By:
java.lang.Thread
- Availability:
- JDK 1.0 or later
Description
The Runnable
interface declares the run()
method that is required for use with the Thread
class. Any class that implements the Runnable
interface must define a run()
method. This method is the top-level code that is run by a thread.
Interface Declaration
public interface java.lang.Runnable { // Methods public abstract void run(); }
Methods
run
public abstract void run()
- Description
- When a
Thread
object starts running a thread, it associates executable code with the thread by calling aRunnable
object'srun()
method. The subsequent behavior of the thread is controlled by therun()
method. Thus, a class that wants to perform certain operations in a separate thread should implement theRunnable
interface and define an appropriaterun()
method. When therun()
method called by aThread
object returns or throws an exception, the thread dies.
See Also
Thread; ThreadGroup; Threads 8