CodesJava

Easy learning with example program codes

Why we call start method in thread


In java multithreading, it is a important point to understand that why we call start method instead of calling run method directly.

start method:

It starts thread to begin execution, JVM calls run method of this thread.
public void start()
IllegalThreadStateException – if the thread was already started.

We call start method in thread because of the following points:

  • The start() method register the thread with Thread Scheduler.
  • It performs all other mandatory activities for a thread.
  • It invokes the run method.
  • Most importantly, it starts a new thread. If we not use the start method and call the run method directly then no new thread will be created and run method will be treated as a normal method.

Related Topics:

Please follow and like us:
Posted in Java   

Core Java Tutorial



Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki