Compare commits

..

No commits in common. "f80521d4a5dd8a2cac6135e2657ebafa8471a823" and "fe9964116ecd10b136c53c56518cd3acc456850e" have entirely different histories.

4 changed files with 0 additions and 68 deletions

View File

@ -1,9 +1,5 @@
package chapter5; package chapter5;
/**
* 获取当前时间
*/
public class Example11 { public class Example11 {
public static void main(String[] args) { public static void main(String[] args) {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();

View File

@ -1,21 +0,0 @@
package chapter5;
import java.util.Enumeration;
import java.util.Properties;
/**
* 获取系统信息
*/
public class Example12 {
public static void main(String[] args) {
// 获取当前系统信息
Properties prop = System.getProperties();
Enumeration names = prop.propertyNames();
while (names.hasMoreElements()) {
String key = (String) names.nextElement();
String value = prop.getProperty(key);
System.out.println(key + "=" + value);
}
}
}

View File

@ -1,28 +0,0 @@
package chapter5;
class Person implements AutoCloseable {
String name;
public Person(String name) {
this.name = name;
}
public void close() {
System.out.println( name + " 要被回收啦!");
}
}
public class Example13 {
public static void main(String[] args) {
Person p1 = new Person("小明");
Person p2 = new Person("大王");
p1 = null;
p2 = null;
System.gc();
for (int i = 0; i < 1000000; i ++) {
// 为了延长程序运行的时间
}
}
}

View File

@ -1,15 +0,0 @@
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");
}
}