开发者

(How) Does TPL use (CLR) Thread Pool?

I am currently researching Task Parallel Library and I read somewhere that TPL actually uses thread pool mechanism from CLR-Level. I couldn't find any article confirming this information. I know, TPL has task queues for each thread and uses some special work-stealing algorithm for balancing. As far as I know, it creates one thread for each processor. Thread pools started to use task objects of TPL since .NET 4.

I can not understand how TPL uses the thread pool. Thread-Pool pattern states, the work items are queued and the free threads in thread pool takes one from this queue. TPL however store the items (tasks) to queues of threads and work-stealing works if needed... Thus, quite differently. Where is my mistake?

extra question: As this was my first Stack Overflow question, I am not开发者_运维问答 sure if it was suitable. Is it?


In TPL, a TaskScheduler is responsible for actually queuing the tasks up for execution. The Default scheduler will use the thread-pool - but I believe it's the new thread pool implementation which actually does the work-stealing cleverness.

Daniel Moth has a blog post with some more details which you may find useful.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜