[Chapter 12] Runnable

#

| Chapter 12 The java.lang Package |

# Runnable

## Name

Runnable

## Synopsis

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 a `Runnable` object's `run()` method. The subsequent behavior of the thread is controlled by the `run()` method. Thus, a class that wants to perform certain operations in a separate thread should implement the `Runnable` interface and define an appropriate `run()` method. When the `run()` method called by a `Thread` object returns or throws an exception, the thread dies.

## See Also

`Thread`, `ThreadGroup`

Process |  | Runtime