Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET Garbage Collection and Native Threads

Tags:

It’s fairly well documented that when .NET's automatic garbage collector runs, it will temporarily pause all running managed threads associated with the application domain. What I haven't been able to discover are details on what happens to native threads created by the application when garbage collection occurs (ie. using _beginthreadex() instead of System.Threading.Thread()). Are they similarly paused or are the left running?

like image 363
Nicholas Avatar asked Dec 08 '09 22:12

Nicholas


1 Answers

Does this help?

"A GC won't stop threads that are not running managed code. Since those threads can't be touching the GC's heap anyways, there's no need for the GC to coordinate with them."

"If a thread was in managed code but called out to native code, it will continue to run. It will be stopped if it returns back to managed code."

like image 78
Jason Evans Avatar answered Sep 25 '22 23:09

Jason Evans