简体   繁体   中英

Does each managed thread have its own corresponding native thread?

I want to know if creating a managed thread in .Net (by calling Thread.Start() ) causes that exactly one native thread to be created in background? So is there a corresponding native thread for a managed threads? If yes, when a managed thread waits or sleeps, does it mean that the corresponding native thread also waits or sleeps?

Yes, a .NET Thread maps to a native operating system thread on all current CLR hosts.

There's an option to map it to something else in the hosting api through the ICLRTaskManager interface , like a fiber, but that is not actually implemented in any of the main-stream hosts. The SQL Server team at the .NET 2.0 time frame attempted this but the project was abandoned when they could not make it reliable enough. This was not tried again. Technically you could run into a custom hosted CLR, started by an unmanaged program, that implemented this mapping but the odds are rather low.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM