Why we call Thread.start() method which in turns calls run method?

后端 未结 12 1153
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 01:40

Why do we call the thread object\'s start() method which in turns calls run() method, why not we directly call run() method?

12条回答
  •  天命终不由人
    2020-11-29 02:29

    The difference is that if we execute the run method by start() method, it creates a new thread where we can execute run method otherwise the run() method will be executed in the thread created by JVM in the public static void main() method. This is exactly the whole point of multithreading, to run a different action on new threads.

提交回复
热议问题