Is Thread is kernel object ?

前端 未结 2 696
臣服心动
臣服心动 2021-01-15 06:13

In this book I read that each instance of the Thread class is actually allocating a kernel object - and this is one of the overheads of using Thread

2条回答
  •  春和景丽
    2021-01-15 06:47

    From MSDN about the instances of Thread:

    An operating-system ThreadId has no fixed relationship to a managed thread, because an unmanaged host can control the relationship between managed and unmanaged threads. Specifically, a sophisticated host can use the CLR Hosting API to schedule many managed threads against the same operating system thread, or to move a managed thread between different operating system threads.

    There also other kinds of threads or thread-like things in .NET. There are thread from the ThreadPool and there are Tasks. Neither of are AFAIK directly bound to OS threads either.

    In summary my understanding of this is that no, .NET threads do not necessarily contain kernel objects.

提交回复
热议问题