The above code gives the following output on my machine. Can someone help me understand how the output of Self State can ever be NEW? Per my understanding NEW is only when a thread has not yet been started.
State 1: NEW
State 2: RUNNABLE
State 3: BLOCKED
Self State 1: NEW
Self State 2: NEW
State 4: WAITING
Self State 3: NEW
State 5: TERMINATED
The getState() call inside the run() method returns the state of the ClassA instance you've passed to the Thread constructor.
That Thread instance will never actually run, it will just have its run() method called.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.