I am working on some code to control the loading of Cpu using Java. I use the following code in my application to get the system boot
public static double getCPULoad() { OperatingSystemMXBean osMBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double load = osMBean.getSystemLoadAverage(); return load; }
But the windows returns a negative value (-1.0). Is there any way to solve this problem?
source share