开发者

Is the threadpool dependant on the window scheduler?

开发者 https://www.devze.com 2023-03-14 14:23 出处:网络
Does the new thread pool in .net 4.0 rely on the windows scheduler or d开发者_开发技巧oes it integrate in some way to take control?The .NET thread pool is essentially a pool of threads that can be sha

Does the new thread pool in .net 4.0 rely on the windows scheduler or d开发者_开发技巧oes it integrate in some way to take control?


The .NET thread pool is essentially a pool of threads that can be shared to execute tasks, process asynchronous I/O and provide timers. The "objects" in the pool are .NET threads and these are implemented using Windows threads. So when the thread pool executes a task on a thread it executes on a Windows thread.

In general a process will contain several threads and some of these threads may belong to the thread pool. When these threads execute concurrently the Windows scheduler is in charge of scheduling the threads to execute on CPU cores by using context switching.

The .NET 4 thread pool does not schedule threads that are executing. However, task that have been queued for work in the thread pool will eventually be assigned to a thread in the thread pool. When the task is complete (this could take 1 ms or 1 year) the thread is recycled to the thread pool. The thread pool can expand and contract to optimize how system resources are used.

You can read a blog entry about what improvements were made to the the .NET 4.0 thread pool: ThreadPool Improvements by Eric Eilebrecht.

0

精彩评论

暂无评论...
验证码 换一张
取 消