Why is OmniThreadLibrary limited to 60 threads when .Net's limit is 32768?

徘徊边缘 提交于 2019-11-29 15:01:15
GolezTrol

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.

You can bypass this stuff by changing the following:

FD_SETSIZE = 1024 in Winsock.pas

CMaxConcurrentWorkers = 1024; in OtlThreadPool.pas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!