I was confused that a thread is automatically stops after executing the return statement or it still remains alive. This is code like:
public void run{
//code goes here
return;//does the thread stops here;
}
Yes, a Java thread stops when its run method terminates.
Now, this information is, let's say, "common knowledge", because the purpose of the Thread class is to wrap a portion of code and terminate when the code finishes executing.
There is no explicit way to assert this behavior by studying the source code of java.lang.Thread because at some point a native method called start0 is executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With