This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The books say that once the thread start() method or run() method completes or is under execution the second call to the run() or start() results in IllegalThreadStateException which should the result in the above case as well . However this code compiles and runs and produces the output:-"runnningrunningrunning"
It is true that start() internally calls run(), but run() and start() are not exactly the same.
Probably inside your run() method, you can try printing the name of the current thread executing it. Then, you might find what happens internally when you call t.run() and t.start().
To check whether your book is correct, you can try adding another t.start() to your code and see if you get an exception.
Minhaj Mehmood wrote:of course not start() method start's a new process/thread, where by calling run() you'll simply running your process in same thread just like any ordinary java method.
yes,by calling run() it doesn't start a new thread it simply run your process in currently running thread or same thread i.e. main in your case.
you can call run() again and again but you can invoke start() only and only once.