Programming question & answer

Java Thread -  How to create Threads in Java?

RRTutors community answer Updated Dec 6, 2019

Answer

There are two ways to create thread in Java

Inherited from the Thread class
Implementing the Runnable interface

Extends Thread

class MyThread extends Thread {  
    public void run() {  
        System.out.println("thread is running...");  
    }  
}

Implements Runnable

class MyThread implements Runnable {  
    public void run() {  
       System.out.println("thread is running...");  
    } 
}