Can I set the number of Threads/CPUs available to the Java VM?
The problem of CPU limits in JVM was solved in Java 10 and is backported to Java 8 from build 8u191:
-XX:ActiveProcessorCount=2
Try to run your program with "affinity" for windows user.
For Example: instead of running "java Test", you should run:"start /affinity 1 java Test" when you need 1 core;"start /affinity 3 java Test" when you need 2 core;....The parameter used should follow this form:
You can use "System.out.println(Runtime.getRuntime().availableProcessors()); to check.