The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
April 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:

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 c07:Frog.java. 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:

http://www.artima.com/designtechniques/cleanup.html

bv




Replies:

Sponsored Links



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