The Thread class is a proxy for a real thread that is in its own memory.
I hope my assumption is true that after the thread completes its run () method, it will become suitable for garbage collection.
Actually there is some code after execution (), this code handles uncaught exceptions.
As soon as the thread dies, its own memory and stack are freed immediately, without requiring a GC. However, a Thread object is like any other object, and it lives until the GC has decided that it can be free, for example. no strong reference to it.
Similarly, FileOutputStream is a proxy for a file in the operating system. You can still reference the object even after the file has been close() or even deleted.
If after returning from run () it does not become suitable for garbage collection, do I need to set a reference to null for it?
You rarely have to do it anywhere. In fact, it is often easier not to refer to the stream in the first place or to use the ExecutorService to manage your streams.
When I have an object with a Thread field, I often die when this object dies, so the field should not be null ed out.
I also use the built-in thread pool used for Fork / Join. This is an easier way to perform tasks in a background thread, since it does not create or destroy threads.
ExecutorService fjp = ForkJoinPool.commonPool();
The right to garbage collection does not necessarily mean that the object will be deleted from memory. It is at the sole discretion of the underlying operating system / JVM when it is garbage collection. But how can one verify (either through a Java program or an external tool) that the object is completely deleted from memory?
You cannot and should not try at all. GC will clean resources when necessary.
If a thread is considered dead as soon as it completes its run () method, why can I still execute isAlive () or getState () on the same thread object? Both calls return false and RUNNABLE respectively.
A stream object is like any other object. You can call methods on it as long as you keep a reference to it.