when a class extends thread class, having methods other than run() then which thread is responsible to execute the methods whether main thread or sub thread created for that class?
class App extends Thread
{
public void run()
{
System.out.println("Running......");
}
public void display()
{
System.out.println("In App class");
}
}
public class Thread_Execution {
public static void main(String[] args) {
App obj=new App();
obj.start();// sub thread
obj.display();//which thread responsible to execute this task.
System.out.println("Main Method"); //Main thread
}
}
New contributor
Ghayathri_Thangadurai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.