Groups | Blog | Home
all groups > c# > june 2004 >

c# : Will it be GC in this condition?


Jon Skeet [C# MVP]
6/25/2004 5:22:53 PM
[quoted text, click to view]

The SacThreadManager can't be garbage collected until the new thread
has finished executing (or at least, until the JIT can tell that the
"this" reference within SacThreadManager.run will never be read again).

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
Peter Lin
6/25/2004 11:02:23 PM
Dear all,
I have a local object tManager in method foo, I create it there and not use
it in the thread that created it anymore.
Will it be GC if the life time of _tsacThreadManager thread is the same
as main thread? I am not sure because the tsacThreadManager thread is running
the tManager's run method all the time.
void foo()
{
tManager= new SacThreadManager();
tManager.SetupThreadManagement();
ThreadStart _st = new ThreadStart(tManager.run);
_tsacThreadManager = new Thread(_st);
_tsacThreadManager.Name="sacThreadManager";
_tsacThreadManager.Start();
}

Peter Lin
6/26/2004 1:07:50 AM
Thanks,
Now, I am more clear for this ....

[quoted text, click to view]
AddThis Social Bookmark Button