I have the following code:
new Thread(new ThreadStart(delegate()
{
while (true)
{
//something
}
})).Start();
Can garbage collector finalize this instance of Thread while it is in the Running state?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The CLR keeps track of all running threads. As long as there are references to objects they won’t be garbage collected. And since the CLR keeps a reference to all running threads the GC won’t touch them.