Sunday, September 4, 2011

Suggest JVM to Run Object Finalization

    /*
    Suggest JVM to Run Object Finalization Example
    This Java example shows how to suggest the JVM to run discarded
    object's finalization methods.
    
    */
    
    package org.best.example;

    public class RunFinalization {
    
    public static void main(String args[])
    {
    /*
    * get current Java Runtime using getRuntime()
    * method of Runtime class.
    */
    Runtime runtime = Runtime.getRuntime();
    
    /*
    * To suggest the JVM to run discarded object's finalization
    * methods, use
    *
    * void runFinalization()
    * method of Runtime class.
    *
    */
    
    runtime.runFinalization();
    }
    
    }

No comments: