This article is a mirror article of machine translation, please click here to jump to the original article.

View: 43107|Reply: 0

[Source] .NET/C# sets the minimum number of threads in ThreadPool.SetMinThreads to improve performance

[Copy link]
Posted on 2021-6-17 18:10:45 | | | |
public static bool SetMinThreads(int workerThreads, int completionPortThreads)

workerThreads: The minimum number of new idle helper threads to be maintained by the thread pool.
completionPortThreads: The number of new minimum idle asynchronous I/O threads to be maintained by the thread pool.

Idle threads are maintained by the thread pool to reduce the time it takes to meet thread requests from the thread pool. Different minimums are reserved for secondary threads and asynchronous I/O threads. To save system resources, more than the minimum number of idle threads will be terminated. Maintenance of idle threads is a background task.

What is the maximum number of threads that can be set in a thread pool?

The maximum value of worker threads is: 32767,The maximum value of asynchronous I/O threads is: 1000If the number is greater than the maximum value that can be set when using the SetMinThreads method, the setting will fail, that is, the SetMinThreads method returns false, indicating that the change failed.

Test code:










Previous:.NET/C# to determine whether a type is nullable or not
Next:.NET/C# Optimized the performance of SslMode for MySQL databases
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com