Creating a Thread
Home ] Up ] [ Creating a Thread ] Stopping a Thread ] Extending the Thread Class ] Implementing Runnable ] An Example ]

 

 

There are two ways of creating a thread:

  1. Using a class that extends the Thread class
  2. Using a class that implements the Runnable interface (note that Thread implements Runnable)

You start a thread by calling Thread's start() method from some thread. The start() method does the following:

  1. Creates a separate thread of execution
  2. Starts that thread of execution at the Thread's or Runnable's run() method
  3. Returns from the start() call in the starting thread.
 
The page was last updated February 19, 2008