加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – 当.Net的限制为32768时,为什么OmniThreadLibrary限制

发布时间:2020-12-15 03:52:11 所属栏目:大数据 来源:网络整理
导读:我最近比较了.NET中的OmniThreadLibrary和ThreadPool,我发现Omni在最大线程中受到更多限制 – 允许60 – 而.NET在.NET 4.0中可以达到32768. 为何如此限制? 解决方法 这是一个历史性的选择,曾经可能被解除.限制仅适用于线程池实现. 对the website给出了解释,
我最近比较了.NET中的OmniThreadLibrary和ThreadPool,我发现Omni在最大线程中受到更多限制 – 允许60 – 而.NET在.NET 4.0中可以达到32768.

为何如此限制?

解决方法

这是一个历史性的选择,曾经可能被解除.限制仅适用于线程池实现.

对the website给出了解释,说明如下:

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.

这个限制的原因是深层内部[OtlTask??Control] TOmniTaskExecutor.WaitForEvent使用具有此限制的MsgWaitForMultipleObjectsEx.如果对具有超过60个并发运行线程的任务池实际需要,则可以规避此限制.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读