Is there a way in Java to find out how many CPUs (or cores) are installed?

前端 未结 5 1497
离开以前
离开以前 2021-02-14 00:46

I want to make some tuning for multithreaded program.

If I know how much threads can really work in parallel I can make the program much more effective.

Is there

5条回答
  •  醉话见心
    2021-02-14 01:43

    One note about the availableProcessors() method, it does not distinguish between physical cpus and virtual cpus. e.g., if you have hyperthreading enabled on your computer the number will be double the number of physical cpus (which is a little frustrating). unfortunately, there is no way to determine real vs. virtual cpus in pure java.

提交回复
热议问题