Getting rid of a Thread
Peter den Haan
posted 15 years ago
No. In fact, the relation between threads and garbage collection is just the other way around: an object only becomes eligible for garbage collection when no thread can reach it (regardless of whether that's the "main" thread or any thread you create). As long as the thread you create is still running, the outer class instance cannot be garbage collected: even if you set all references to null, the inner Thread subclass still has an implicit reference to it making it reachable.Originally posted by Paul Keohan:
If a Thread class is created as in inner class that's started by the outer class; will it automatically stop if the outer class object is set to null?