Can we call run() method directly to start a new thread

No, you can not directly call run method to start a thread. You need to call start method to create a new thread.
If you call run method directly , it won’t create a new thread and it will be in same stack as main.
Lets understand with the help of example:
When you run above program , you will get below output:
As you can see when we are directly calling run method, it is not creating new threads.

If you use start instead of run in above example:

When you run above program , you will get below output:

Thread is running :0
Thread is running :0
Thread is running :1
Thread is running :1
Thread is running :2
Thread is running :2
Thread is running :3
Thread is running :3
Thread is running :4
Thread is running :4

You can not directly call run method to create a thread, you need to call start method to create a new thread.

You can go through core java interview questions for beginners and experienced for more such questions.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *