Create a thread that extending the Thread class. - Java Thread

Java examples for Thread:Thread Operation

Description

Create a thread that extending the Thread class.

Demo Code

class CountDownClock extends Thread
{
  public void run()
  {//  ww w.j a va 2 s  .c  o  m
    for (int t = 20; t >= 0; t--)
    {
      System.out.println("T minus " + t);
      try
      {
        Thread.sleep(1000);
      }
      catch (InterruptedException e)
      {}
    }
  }
}


public class Main
{
      public static void main(String[] args)
      {
           Thread clock = new CountDownClock();
           clock.start();
      }
}

Related Tutorials