availableProcessors() method of Runtime returns the number of processors available to the Java virtual machine.
This value may change during a particular invocation of the virtual machine. Applications that are sensitive to the number of available processors should therefore occasionally poll this property and adjust their resource usage appropriately.
Example:
package java_availableprocessors;
public class Java_availableProcessors {
public static void main(String[] args) {
System.out.print("availableProcessors = "
+ Runtime.getRuntime().availableProcessors() + "\n");
}
}

No comments:
Post a Comment