Threading and garbace collection

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi all, I have written an application that uses threading (25 threads in
fact!!) and obviously I want to ensure that everything is cleaned up nicely
when the program finally exits.

So, question is, for each thread that is I instantiate, do I have to do
anything to clean up the thread or with the .NET garbage collection take
care of memory deallocation?

TIA
Mark
 
If you are using managed code then GC will take care of it.

For sure. The threads themselves are controlled by, and run within, the CLR.
In face, every application runs as a thread, so of course the GC will be
active till the end.

John, don't forget to set the IsBackground property of your threads to true,
so that the app can exit waiting for them to terminate.

- Stephen
 
Back
Top