what's the proper way to use a ThreadPool?

前端 未结 4 659
深忆病人
深忆病人 2020-12-15 04:40

If my understanding of the way the ThreadPool works is correct, one of its purposes is to limit the number of worker threads within a process that can be created at a given

4条回答
  •  天涯浪人
    2020-12-15 05:19

    ThreadPool.SetMaxThreads(5, 5)

    means the number of active thread is 5 (if you have more than 5 cpu core), does not mean that the ThreadPool can only create 5 threads. The ThreadPool maximum number of threads = CPU Core * 250.

    After Thread.Sleep, the thread is inactive, so it will not affect the execution of other threads.

提交回复
热议问题