Sobes.tech
Junior

What is the difference between the start() and run() methods in Java?

sobes.tech AI

Answer from AI

  • start():
    • Starts a new thread.
    • Calls the run() method in this new thread.
    • The operating system manages thread scheduling and execution.
  • run():
    • Contains the code that will execute in the thread.
    • If called directly (e.g., thread.run()), it will execute as a normal method in the current thread.
Method Execution Thread Creation
start() In a new thread created by JVM Yes
run() In the current thread, as a normal method No