Overriding
of start ()method
If we override a start() method, then our start() method will be executed just like a normal method call and new thread won’t be created.
Example:
class MyThread extends Thread
{
public void start()
{
System.out.println("start method");
}
public void run()
{
System.out.println("run method");
}
}
If we override a start() method, then our start() method will be executed just like a normal method call and new thread won’t be created.
Example:
class MyThread extends Thread
{
public void start()
{
System.out.println("start method");
}
public void run()
{
System.out.println("run method");
}
}
class Test
{
public static void main(String args[])
{
Mythread t=new MyThread();
t.start();
System.out.println("main method");
}
}
{
public static void main(String args[])
{
Mythread t=new MyThread();
t.start();
System.out.println("main method");
}
}
Output: