Nikhil Nikhil - 2 months ago 25
Java Question

Thread scheduler registration?

In java, does run() register a thread in a thread scheduler?
What about construct(),start() and register() ?

Answer

In java, does run() register a thread in a thread scheduler?

No. If you call the run() method directly, it is called as a normal method; i.e. it runs on the current thread, not a new one.

What about construct(),start() and register()

The start method creates a new thread, and in the process the thread will be registered with the scheduler. (However, the scheduler is a nebulous concept in Java. It is implied that one must exist, but its implementation and behavior are typically left to the host operating system. A pure Java program has almost no control over the way that the thread scheduler actually works.)

There are no construct() or register() methods in the Thread API. If you are referring to the Thread constructors, they only create a Thread object, and NOT the underlying thread that will do the work. The latter is only created when start() is called.