What is the difference between Thread.start() and Thread.run()?
Why do we call the
start()
method, which in turn calls therun()
method?
No that's imprecise. start()
in turn does not call the run method.
instead it starts the thread which executes the run method. This is native.
Can't we directly make a call to
run()
?
If you call run()
directly you don't start the thread, you just execute the method on the same caller method.
Please give an example where there is a difference.
There are millions on the web. Hence I don't duplicate.
No, you can't. Calling run will execute run()
method in the same thread, without starting new thread.
Actually thread.start()
creates a new thread and have its own execution scenario.
but thread.run()
not creating any new thread, instead it execute the run method in the current running thread.
So guys if you are using thread.run()
then think that what is the use of multi-threading if you want only one thread execute all run method.