public class Main {
/**
* Displays the number of processors available in the Java Virtual Machine
*/
public void displayAvailableProcessors() {
Runtime runtime = Runtime.getRuntime();
int nrOfProcessors = runtime.availableProcessors();
System.out.println("Number of processors available to the Java Virtual Machine: " + nrOfProcessors);
}
/**
* Starts the program
*
* @param args the command line arguments
*/
public static void main(String[] args) {
new Main().displayAvailableProcessors();
}
}
代码来自[url=http://topic.csdn.net/u/20110505/06/800727af-49e6-4f48-abd8-229c3927aeae.html]CSDN[/url]