Does each managed thread have its own corresponding native thread?

前端 未结 1 449
温柔的废话
温柔的废话 2020-12-11 16:13

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

1条回答
  •  北海茫月
    2020-12-11 16:50

    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.

    0 讨论(0)
提交回复
热议问题