Java Thread -  How to create Threads in Java?

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...");  
    } 
}

 


Subscribe For Daily Updates

Flutter Questions
Android Questions