About Question enthuware.ocpjp.v7.2.1441 :
Posted: Sat Dec 12, 2015 11:50 am
It seems that the answer "A thread dies when the run( ) method ends." is less accurate that the answer "A thread dies when the start() method ends". It is because of two reasons:
1. Method run() could be executed without starting a new thread, so when it ends the execution the thread keeps the NEW State.
2. Decompiling of the Thread class shows that the start() method wraps around a native private method start0() which calls run() method and set a thread state to TERMINATED inside.
In both cases we can not definitely say whether a thread dies after finishing run() execution or not(in the 1st case the answer is always NO) . However it is always true that every thread is died when it finishes the start() execution .
1. Method run() could be executed without starting a new thread, so when it ends the execution the thread keeps the NEW State.
2. Decompiling of the Thread class shows that the start() method wraps around a native private method start0() which calls run() method and set a thread state to TERMINATED inside.
In both cases we can not definitely say whether a thread dies after finishing run() execution or not(in the 1st case the answer is always NO) . However it is always true that every thread is died when it finishes the start() execution .