What happens if I dereference a thread without doing any sort of cleanup/shutdown? Does it just get garbage collected at some unknown point (hopefully not when it is actually running)?
Peter den Haan
posted 14 years ago
In general, an object will be eligible for garbage collection if it is no longer reachable. As the JLS (12.6.1) puts it, A reachable object is any object that can be accessed in any potential continuing computation from any live thread. This applies to Thread objects, too - as long as the thread runs, its Thread object will be reachable (cf. Thread.currentThread()) and cannot be garbage collected. - Peter