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
finalize() method call unpredictable???
Posted by Padma on April 19, 2000 at 4:37 PM
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:
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!