Why does the start() automatically call the run()??What happens if the developer explicitly calls run() and also please explain the difference between above two scenarios??
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2407
posted
0
Calling run directly will execute that method in the current thread. Only by calling start will a new thread be created for the run method to execute in.
Sanath Ramesh kumar wrote:Why does the start() automatically call the run()??
Because the code for start() calls the native method start0(), which has code that says, "Start a new thread of execution, and in it, call this object's run() method."
In other words, it's because that's how the code is written, just like any other time one method calls another.