Clr_via_c #. 3rd translation [25.6 CLR thread and Windows Thread]

Source: Internet
Author: User

25.6 CLR threads and Windows threads. CLRThread andWindowsThread

 

Today, CLR uses the thread processing capability of windows. Therefore, part V of this chapter focuses on the thread processing capability exposed by windows to developers. I will explain how the thread works in windows and how the CLR changes the thread behavior (if possible ). However, if you want to learn more about threads, you are advised to read some of my previous books on this topic, such as my book windows via C/C ++ (Microsoft press, 2007 ).

 

Although a CLR thread today is mapped directly to a Windows Thread, the Microsoft CLR team reserves the right to detach it from a Windows Thread in the future. One day, CLR may introduce its own logic thread concept, so that a CLR logic thread is not necessarily mapped to a physical Windows Thread. It is said that logical threads will use much less resources than physical threads, so they can run a large number of logical threads on a very small number of physical threads. For example, CLR can determine that one of your threads is in the waiting state and re-allocate that thread to perform a different task. The benefits of this solution are: Simpler coding, fewer resources used, and potential performance improvement. Unfortunately, the CLR team still has a lot of work to implement this solution, so it is unlikely that the CLR will launch this function in the near future.

 

for you, all this means that when manipulating a thread, Code should make as few assumptions as possible. For example, P/invoke should be avoided for Windows functions because these functions do not know anything about CLR threads. By avoiding the use of local Windows functions and sticking to the FCL (framework class library) type, your code will be able to enjoy this improvement immediately after the performance is improved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.