The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 2000



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.


More Info on Garbage Collection and Finalizers

Posted by Bill Venners on April 20, 2000 at 4:38 AM

> Hello,

> I am learning java and find your book Thinking in Java (TIJ2.pdf) really good.

> There was one problem that I faced while executing one of the e.g. the code for This compiled w/o any problem. When I executed it the first time with a command line parameter of "finalize", I got the o/p as specified in the book. But on subsequent executions, after the Frog, Amphibian and Animal finalize, the program terminated!

> I didn't see these messages:

> LivingCreature finalize
> finalizing Characteristic is alive
> finalizing Characteristic has heart
> finalizing Characteristic can live in water

> Is it because Garbage Collection is not predictable? Maybe I need to review my concepts, but any light in this direction is most certainly appreciated!

(Actually, Thinking in Java is Bruce's book. You unknowingly
fled his web site for mine.)

This article should clear up your questions about finalization
in Java:



Sponsored Links

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