当.Net的限制为32768时,为什么OmniThreadLibrary限制为60个线程? [英] Why is OmniThreadLibrary limited to 60 threads when .Net's limit is 32768?

查看:194
本文介绍了当.Net的限制为32768时,为什么OmniThreadLibrary限制为60个线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我正在比较.NET中的OmniThreadLibrary和ThreadPool,我发现Omni在最大线程( 60允许)中受到的限制更多,而.NET可以升级到 32768 在.NET 4.0中。



为什么这样的限制?

解决方案

这是一个历史性的选择,曾经被取消。限制只有线程池实现。



有关网站,说明如下:


60个并发线程的限制仅适用于线程
池。线程池旨在快速执行许多小的
请求,而不是作为极少活动线程的存储。



您可以跳过线程池并使用OTL任务直接这样你
可以创建数百个。


这个限制的原因是深入 [OtlTask​​Control] TOmniTaskExecutor.WaitForEvent 使用具有此限制的MsgWaitForMultipleObjectsEx。如果对于具有超过60个同时运行的线程的任务池发生真正的需求,则可以绕过此限制。


I was recently comparing OmniThreadLibrary and ThreadPool that is in .NET and I found that Omni is much more restricted in maximum threads — 60 allowed — while .NET can go up to 32768 in .NET 4.0.

Why such a limit?

解决方案

It's an historic choice that once may be lifted. The limit is only there on the threadpool implementation.

An explanation is given on the website, stating the following:

The limitation of 60 concurrent threads only applies to the thread pool. Thread pool is designed for fast execution of many small requests, not as a storage for rarely-active threads.

You can just skip thread pool and use OTL tasks directly. That way you can create many hundreds of them.

The reason for this limit is that deep inside [OtlTaskControl]TOmniTaskExecutor.WaitForEvent uses MsgWaitForMultipleObjectsEx which has this limitation. If a real need occurs for task pools with more than 60 concurrently running threads, this limitation could be circumvented.

这篇关于当.Net的限制为32768时,为什么OmniThreadLibrary限制为60个线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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