Main difference is that when program calls
start() method a new Thread is created and code inside run() method is executed
in new Thread while if you call run() method directly no new Thread is created
and code inside run() will execute on current Thread.
If you want to perform time consuming task than
always call start() method otherwise your main thread will stuck while
performing time consuming task if you call run() method directly.
Another difference between start vs run in Java
thread is that you can not call start() method twice on thread object. once
started, second call of start() will throw IllegalStateException in Java while
you can call run() method twice.
No comments:
Post a Comment