473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Will it be GC in this condition?

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();
}

Thanks..
Nov 16 '05 #1
2 1030
Peter Lin <no**************@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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Thanks,
Now, I am more clear for this ....
Peter Lin <no**************@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).


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tristan | last post by:
Is there any support for a negative condition in If statements in PHP. Some tutorials ive found say that you can use the if!(condition)cmd; syntax. however i always get an error when i use that....
23
by: Antoon Pardon | last post by:
I have had a look at the signal module and the example and came to the conclusion that the example wont work if you try to do this in a thread. So is there a chance similar code will work in a...
2
by: Luis | last post by:
In the code below I have a Response.End in the middle of a Do loop that is run if the condition in a nested 'If...' statement is not met. Will the rs and conn objects be closed and destroyed if the...
1
by: Joel | last post by:
As my registry start condition was working fine, now it's not working anymore Here are the kind of parameter I use in VSNEt2003: A) Registry : Name : Pipo; Property : PROP1; RegKey...
0
by: djozy | last post by:
....which I have on my ASP.NET webform. I press button for inserting data's from database in datagrid, that satisfy condition, lets say hair='black'. In datagrid I can see all data's with that...
4
by: joh12005 | last post by:
Hello, i posted for suggestions a little idea even if it still needs further thoughts but as i'm sure you could help :) if would like to implement some kind of Condition class which i coud...
0
by: Rob R. Ainscough | last post by:
I'm pretty frustrated right now, but I'm unable to get a Launch Condition to work at all in my Condition statement of a Registry entry. (working on a Deployment Project) 1. In Launch...
10
by: apparker | last post by:
I'm creating a new GUI for a program and it is for a medical exam. There are so many different things to ask someone during a history it wastes too much space to make checkboxes for everything so I...
1
by: Pathik | last post by:
Hi All, I have to get the values of "reading" and "value" elements of context Person/Category/Group/ser.These values must be on condition based,means I have to get the values of "reading" and...
0
by: Vajrala Narendra | last post by:
Hi all, TO my .net setup project i want to add a launch condition for crystal report installation. In my prerequisities i selected Crystal reports fro basic visual studio 2008 (x64, x86) in my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.