static int i = 1;
public RubbishRelease() {
System.out.println(i++);
}
public void finalize() {
System.out.println("finalize...");
}
public static void main(String[] args) {
for (int i = 0; i < 100000; i++) {
new RubbishRelease();
new RubbishRelease();
new RubbishRelease();
System.gc();
}
System.out.println("over!");
}
试试这个~比较下速度,非常明显,所以gc还是不能随便适用嘀~