Hi,
It is one of the
Java Ranch policies to ask one question per post. Now coming to your question....
and we go outside of its scope
. I did not understand what did you mean by
we. If the run method of your thread runs infinitely like
Your program will never terminate.
Yes you can give a name to your thread either through the thread constructor or by invoking the method setName().
Let us see the following code...
Garbage Collector is a low-priority daemon thread whose sole work is acquisition of High-priority threads. I won't go into the details of what a daemon thread is because it is a little more complex than normal user threads. Once a thread or any object becomes eligible for Garbage Collection the memory will eventually be reclaimed..it is only a matter of time. I would request you to go through Mutli-threading concepts that will clear your doubts further.
Always remember you cannot force garbage collection. You can only make objects eligible for garbage collection.
Henry Wong is the best person to answer threading. I believe i could clear your doubts.Hope it helps.