标签:
java.lang.Runtime.availableProcessors() 方法返回到Java虚拟机的可用的处理器数量。此值可能会改变在一个特定的虚拟机调用。应用程序可用处理器的数量是敏感的,因此偶尔查询该属性,并适当地调整自己的资源使用情况.
以下是声明java.lang.Runtime.availableProcessors()方法
public int availableProcessors()
NA
此方法返回到虚拟机的最大可用的处理器数量;决不会小于一个
NA
下面的例子说明了如何使用的lang.Runtime.availableProcessors()方法。
package com.yiibai; public class RuntimeDemo { public static void main(String[] args) { // print a normal message System.out.println("Hello world!"); // check the number of processors available System.out.println(""+Runtime.getRuntime().availableProcessors()); } }
让我们来编译和运行上面的程序,这将产生以下结果:
Hello world! 4
Java Runtime.availableProcessors()方法
标签:
原文地址:http://www.cnblogs.com/langtianya/p/5136666.html