If the start() method of a thread internally calls the run() method, then why don't we directly call the run() method in our code? What are the issues involved in doing so?
The start
method makes sure the code runs in a new thread context. If you called run
directly, then it would be like an ordinary method call and it would run in the context of the current thread instead of the new one. The start
method contains the special code to trigger the new thread; run
obviously doesn't have that ability because you didn't include it when you wrote the run
method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With