A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Overriding of start ()method

What is Multithreading?

What will happen if we override the 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.

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

Output:




LEARN TUTORIALS

.

.