And this thread object is instantiated and started in a local method
Assuming the startThread method is called in some other method, what will happen to the Thread object 'tObj' after the end of execution of startThread method? Will 'tObj' thread continue to execute or could it be garbage collected by the JVM?
The object still keeps running until the object is not reached by the any live reference.
GC of java uses various techniques such as mark and sweep/ refernence counting algorithms to check for the active references. in case the object is not reached by the live refernces object will Garbage collected.
Originally posted by vinay prasad: The object still keeps running until the object is not reached by the any live reference.
Welcome to JavaRanch!
I wanted to point out that as long as a Thread is running, it will be referenced by its ThreadGroup, and as long as a ThreadGroup contains at least one running thread it, in turn, is referenced by its parent ThreadGroup; therefore, Jose is quite correct in stating that the Thread will continue to run forever (until, of course, something happens to make it stop.) The important point is that under no circumstances will the GC collect a running Thread; it's designed that way quite deliberately.