Question about a Thread
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   eimi_nos
Posted On:   Friday, September 20, 2002 03:13 PM

Suppose that a thread, say threadA, has started, which takes some duration of time to perform, but that the reference to threadA is set to null immediately after the invocation of start() to run threadA (which I won't do usually, but here assumed).
I understand that the object threadA is not garbage collected while it is working.


My question is this; is the object threadA garbage collected (if System.gc() is invoked) surely after threadA terminated? What is the difference between alive thread and non-alive thread as to the aspect of garbage collecting?

Re: Question about a Thread

Posted By:   Kian_Parsee  
Posted On:   Wednesday, October 16, 2002 11:28 AM

I believe your thread will still be alive if you set the reference to null. A thread is "alive" as long as it has not finished processing.



A note on System.gc(): this does not necessarily invoke the garbage collector immediately.



Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. The key word here is "suggests".
About | Sitemap | Contact