Runtime
This commit is contained in:
parent
a6c121d9a1
commit
f80521d4a5
@ -1,4 +1,15 @@
|
||||
package chapter5;
|
||||
|
||||
/**
|
||||
* 获取当前虚拟机信息
|
||||
*/
|
||||
|
||||
public class Example14 {
|
||||
public static void main(String[] args) {
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
System.out.println("处理器个数:" + rt.availableProcessors());
|
||||
System.out.println("空闲内存:" + rt.freeMemory()/1024/1024 + "MB");
|
||||
System.out.println("虚拟机中的内存总量:" + rt.totalMemory()/1024/1024 + "MB");
|
||||
System.out.println("最大可用内存:" + rt.maxMemory()/1024/1024 + "MB");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user