...
- There is no fixed time at which finalizers must be executed; this detail is JVM dependent. The only guarantee is that any finalizer method that executes will do so sometime after the associated object has become unreachable (detected during the first cycle of garbage collection), and sometime before the garbage collector reclaims the associated object's storage (during the garbage collector's second cycle). Execution of an object's finalizer can be delayed for an arbitrarily long time after the object becomes unreachable. Consequently, avoid implementing time-critical functionality in an object's
finalize()
method. For instance, closing file handles is not recommended.
...