1

On our Windows Server 2019, we have 36 cores and 72 logical processors, as seen in Task Manager CPU performance window. And, also, if from command prompt, if I run the command.

echo %NUMBER_OF_PROCESSORS%

It tells me 72. However, from within Java program, if I run the following code snippet,

    int cores = Runtime.getRuntime().availableProcessors();
    String procrs = System.getenv("NUMBER_OF_PROCESSORS");

the value of cores and procrs show me, as 36, each. Same system variable, NUMBER_OF_PROCESSORS is showing me different result from a command prompt vs from within Java program. Why?

I understand, the system variable, NUMBER_OF_PROCESSORS gets automatically set and does not need to be manually intervened ever. Microsoft documentation link on processor groups stated that:

Support for systems that have more than 64 logical processors is based on the concept of a processor group, which is a static set of up to 64 logical processors that is treated as a single scheduling entity. Processor groups are numbered starting with 0. Systems with fewer than 64 logical processors always have a single group, Group 0.

Is this the reason of showing me 36 from within my Java code snippet?

Dr. Debasish Jana
  • 6,980
  • 4
  • 30
  • 69
  • Particularly https://stackoverflow.com/a/52629195/139985 – Stephen C May 08 '20 at 10:00
  • See also https://serverfault.com/questions/646994/how-is-number-of-processors-env-variable-generated – Stephen C May 08 '20 at 10:11
  • @StephenC, one of my question was: Why same system variable, NUMBER_OF_PROCESSORS is showing me different result from a command prompt vs from within Java program. – Dr. Debasish Jana May 08 '20 at 11:49
  • It is not Java doing this. The Java source code doesn't use or update that environment variable. So my guess is that it is something to do with the way that you are running Java. ** – Stephen C May 08 '20 at 13:38

0 Answers0