读书人

取得处理器的数量

发布时间: 2012-10-24 14:15:58 作者: rapoo

获得处理器的数量

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();    }}


代码来自CSDN

读书人网 >编程

热点推荐