The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
June 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

System.gc()

Posted by Jeong-hoon Kang on June 28, 2000 at 4:54 AM

class Book{
boolean checkedOut = false;
Book(boolean checkOut){
checkedOut = checkOut;
}

void checkIn(){
checkedOut = false;
}

public void finalize(){
if(checkedOut)
System.out.println("Error : checked out");
}
}

public class DeathCondition{
public static void main(String[] args){
Book novel = new Book(true);
novel.checkIn();
new Book(true);
System.out.println("ABC"); //22
System.gc();
}
}
When garbage collecter does its job?
and why does not the above program print "Error : checked out" without Line 22 ?



Replies:
  • System.gc() Matt Gerrans July 01, 2000 at 2:54 AM (0)

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us