是否每个托管线程都有自己的相应的本地线程? [英] Does each managed thread have its own corresponding native thread?

查看:187
本文介绍了是否每个托管线程都有自己的相应的本地线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,如果在.NET中创建一个托管线程(通过调用 Thread.Start())会导致只有一个本地线程在后台创建? 那么,有没有一个管理线程对应的天然线程? 如果是的话,当一个管理线程等待,睡觉,岂不是相应的本地线程同时等待,睡觉?

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?

推荐答案

是的,一个.NET线程映射到本机操作系统线程上目前所有的CLR主机。

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

有一个选项,它通过 ICLRTaskManager接口映射到托管API别的东西一样的纤维,但实际上没有在任何主流的主机执行。在.NET 2.0的时间框架的SQL Server团队尝试这一点,但该项目被放弃,当他们不能让它不够可靠。这是不是又试了一次。从技术上讲,你可能会遇到托管CLR自定义,非托管的程序启动,即实现了这个映射,但几率相当低。

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.

这篇关于是否每个托管线程都有自己的相应的本地线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆