Efficient Number of Threads

前端 未结 6 538
小鲜肉
小鲜肉 2020-12-28 10:23

I want to optimize my application number of threads. Almost all of them have IO beside CPU usage in an equal value. How much is the efficient number of threads when there ar

6条回答
  •  攒了一身酷
    2020-12-28 11:10

    Performance is far from the only reason to use threads.

    Basically, any multi-thread program can be simulated with a single more complex thread, so what the threads are actually doing is simplifying your code, not necessarily making it faster.

    That said, if your app could make use of multiple cores or multiple disk heads functioning at the same time, then threads could make it easy to exploit that. In that case, you probably don't need any more threads than you have separate cores or heads, because process switching has a definite cost.

提交回复
热议问题