It seems that you are tripping on the common pitfall with unterstanding threads in Java: the thread itself is not a Java object. It is a native resource (thread of execution). It will be "removed from memory" as soon as it has finished running its code.
The instance of Thread
, on the other hand, is just a plain Java object with the same lifecycle as any other object—except for the extra rule that it stays reachable at least as long as the underlying native thread is alive. This is implied by the fact that you can always call Thread.currentThread()
.
So, if you retain a reference to a Thread
instance in charge of a dead thread, it will not magically disappear and all its methods will continue to operate as specified. You can hold on to it for as long as desired.
Regarding your question 2, "removing" an object from memory is a virtually meaningless term. The runtime itself has in fact no idea about the collected objects—they are those which it has forgot about.