Programs to demonstrate multithreading with extends.

extend thread class

in this tutorial we are learn about extending the thread class.we create java.lang.thread class that extend the class.that class override the run() method that available in thread class.
inside a run() method thread begin its life. we create an object of are new class  execution of thread are started by start() method. on the thread object start() invoking the run() method.         


//Programs to demonstrate multithreading with extends.       

class mthread extends Thread

 

{

 

public void run()

{

 

System.out.println("current thread started runnning...");

 

}

 

}

 

class mythread

{

 

public static void main(String[] args)

 

{

 

mthread mt=new mthread();

mt.start();

 

}

 

}

 

Output:-

Programs to demonstrate multithreading with extends.

Post a Comment

0 Comments