I have a simple question about Java GC. Some example :
Object instance = new Object();
longMethod(instance);
...
// First example
private void longMethod(Object arg) {
Thread.sleep(1000 * 60 * 60)
// this method works 1hr. Does it keep reference to Object and GC canot release it?
}
//Seconde example
private void longMethod(Object arg) {
arg = null;
Thread.sleep(1000 * 60 * 60)
// we clear reference in method. Can GC relese Object now?
}
So what is lifecycle of "instance" in both cases? Thanks.