[quoted text, click to view] Peter Lin <nospam_peter_lin@spirox.com.tw> wrote:
> 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();
> }
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