Java Program to Create a Thread by Implementing a Runnable Interface

You are currently viewing Java Program to Create a Thread by Implementing a Runnable Interface

Java program to create a thread by implementing a Runnable interface

// Java program to create a thread by implementing
// Runnable interface

public class Main implements Runnable {
  public static void main(String[] args) {
    Main m = new Main();

    Thread thrd = new Thread(m);

    thrd.start();

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

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

Output

Outside the thread
Thread Executed

Ranjith

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

Leave a Reply