在下面的示例程序中,在执行Thread.sleep(1000)行之前将有多少对象被垃圾收集?
public class GCExample {
public static void main(String[] args) throws InterruptedException {
GCExample gc = new GCExample();
gc.doSomeThing();
Thread.sleep(1000);
}
public void doSomeThing(){
Object[] obj = new Object[2];
for(int i=0;i<obj.length;i++){
obj[i] = new Object();
}
}
Run Code Online (Sandbox Code Playgroud)
}
| 归档时间: |
|
| 查看次数: |
171 次 |
| 最近记录: |