Java Program to Create a Thread by Extending the Thread Class

Java program to create a thread by extending the Thread class

// Java program to create a thread by extending 
// the Thread class

public class Main extends Thread {
  public static void main(String[] args) {
    Main thrd = new Main();

    thrd.start();

    System.out.println("Outside the thread");
  }

  public void run() {
    System.out.println("Thread Executed");
  }
}

Output

Outside the thread
Thread Executed
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment