praneeth kumar
Its given in K&B that finalize method will be called only once and the second time,the object will be GCed directly.Is it the same even if we invoke finalize method explicitly?In other words,if we explicitly invoke finalize method,will it be invoked again before being GCed?
if you invoke finalize method explicitly on any object, finalize will be invoked then also on that object by JVM. But JVM invokse only once on that object. If you try to resurrect that object through finalize, and when again that object becomes elligible for garbage collection, this time JVM wont invoke finalize() on it.
here is a sample code::
somehow System.gc() did perform garbage collection (atleast on my system) and the O/P I got::
E:\Priyam>
java Test 102010
Though I have not resurrected the object, but you can try your self...
[ July 23, 2007: Message edited by: Priyam Srivastava ]