ThreadPool SetMaxThreads and SetMinThreads Magic Number

后端 未结 3 1551
情话喂你
情话喂你 2020-12-08 19:45

Is there a magic number or formula for setting the values of SetMaxThreads and SetMinThreads for ThreadPool? I have thousands of long-running methods that need execution bu

3条回答
  •  执笔经年
    2020-12-08 20:04

    Typically, the magic number is to leave it alone. The ThreadPool does a good job of handling this.

    That being said, if you're doing a lot of long running services, and those services will have large periods where they're waiting, you may want to increase the maximum threads to handle more options. (If the processes aren't blocking, you'll probably just slow things down if you increase the thread count...)

    Profile your application to find the correct number.

提交回复
热议问题