The following code when run on Windows platform, normally returns the correct
results. But when we use the intel's hyperthreading then it returns twice the
number of processors available.
The reason is that java.lang.Runtime.availableProcessors() is returning the
number of logical processors, rather than the physical ones.
import java.lang.Runtime.*;
public class FindProcessor
{
public static void main(String argv[]) {
Runtime rt = java.lang.Runtime.getRuntime();
System.out.println("The available processors are " +
rt.availableProcessors());
}
}
results. But when we use the intel's hyperthreading then it returns twice the
number of processors available.
The reason is that java.lang.Runtime.availableProcessors() is returning the
number of logical processors, rather than the physical ones.
import java.lang.Runtime.*;
public class FindProcessor
{
public static void main(String argv[]) {
Runtime rt = java.lang.Runtime.getRuntime();
System.out.println("The available processors are " +
rt.availableProcessors());
}
}
- relates to
-
JDK-6515172 Runtime.availableProcessors() ignores Linux taskset command
- Resolved