What is the relationship between number of CPU cores and number of threads in an app in java?

后端 未结 7 779
臣服心动
臣服心动 2021-01-31 00:07

I\'m new to java multi-threaded programming. The question that has came to my mind is that how many threads can I run according to the number of my CPU

7条回答
  •  北海茫月
    2021-01-31 00:37

    Best performance will be when number of cores(NOC) equals number of thread (NOT), because if NOT > NOC then processor should switch context or OS will try to do that work, which is expensive enough opperation. But you have to understand that it impossible to have NOC = NOT on Web Servers because you can't predict how much clients will be at the same time. Take a look on load balancing concept to solve this issue in best way.

提交回复
热议问题