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:
|