Multithreading by extend method




public class multithreading extends Thread {
// we extend to thread class, the class object is treated aa s thread object.
 
    public void run() {
        System.out.println("Thread is running ");
    }
   
    public static void main(String[] args) {
        multithreading obj =new multithreading();
        obj.start(); // means class object start then automaticaly run method starts. and whatever their is insicde run method it get executed
 
    }
   
   
}

OUTPUT
Thread is running

No comments:

Post a Comment