Small Java code - how to get number of processors:
int noOfProcessors = 0;
try
{
Runtime rt = Runtime.getRuntime();
Class rtClass = rt.getClass();
java.lang.reflect.Method availProcessorsMethod = rtClass.getMethod("availableProcessors", null);
noOfProcessors = ((Integer)availProcessorsMethod.invoke(rt, null)).intValue();
}
catch (Exception ex)
{
// probably old JDK
}
No comments:
Post a Comment