Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...