Thread lifetime in java

3

When an object, from a class that implements a thread, is destroyed (loses reference) does the thread for that object stop?

    
asked by anonymous 06.07.2016 / 14:54

1 answer

4

According to the Java documentation in System.Threading.Thread:

  

It is not necessary to retain a reference to a Thread object once you have started the thread. The thread continues to execute until the thread procedure is complete.

That is, it is not necessary to keep a reference to a Thread after starting it, the JVM manages the Thread and only terminates its use when run () runs to its end.

Though it's interesting to keep the reference for thread control purposes.

I hope I have helped.

    
06.07.2016 / 15:02