right, by invoking ONCE the finalize method of your object. From the Object API:
protected void finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
According to the mark & sweep algorithm the first time it marks objects and then the second time it sweeps .. so any unmarked objects would be collected the second time ..pls correct me if i am mistaken
Neither the JLS nor the JVMS require the use of the mark & sweep algorithm for garbage collection. In fact, the choice of the algorithm is completely up to the JVM vendor. Thus, such assumptions cannot be made.
If your finalize() method "resurrects" the object by making it reachable again, then the next time it becomes unreachable, the garbage collector will not call finalize() a second time.
Post by:autobot
Those are the largest trousers in the world! Especially when next to this ad:
a bit of art, as a gift, that will fit in a stocking