Wu Yuxiong - born naturally develop common java class library study notes: RumTime class

public class RuntimeDemo01{
    public static void main(String args[]){
        RUN Runtime = Runtime.getRuntime ();     // instantiate operation static Runtime category 
        System.out.println ( "JVM maximum amount of memory:" + run.maxMemory ());     // observed maximum memory, in accordance with different machines, the environment will be different 
        System.out.println ( "JVM amount of free memory:" + run.freeMemory ());     // get the program to run free memory
        String str = "Hello " + "World" + "!!!" 
                +"\t" + "Welcome " + "To " + "MLDN" + "~" ;
        System.out.println(str) ;
        for(int x=0;x<1000;x++){
            STR + = X;             // circulation content, generates a plurality of garbage 
        }
        System.out.println ( ", the JVM amount of free memory after the operation String:" + run.freeMemory ());
        run.gc ();         // garbage collection, freeing up space 
        System.out.println ( ", JVM amount of free memory after garbage collection:" + run.freeMemory ());
    }
};
public class RuntimeDemo02{
    public static void main(String args[]){
        RUN Runtime = Runtime.getRuntime ();     // retrieve instances of object class Runtime 
        the try {
            run.exec ( "Notepad.exe");     // call to this program, this method requires exception handling 
        } the catch (Exception E) {
            e.printStackTrace ();     // print exception information
             // System.out.println (E); 
        }
    }
};
public class RuntimeDemo03{
    public static void main(String args[]){
        RUN Runtime = Runtime.getRuntime ();     // retrieve instances of object class Runtime 
        Process P = null ;     // definition of the process variable 
        the try {
            P = run.exec ( "Notepad.exe");     // call to this program, this method requires exception handling 
        } the catch (Exception E) {
            e.printStackTrace ();     // print exception information
             // System.out.println (E); 
        }
         the try {
            Thread.sleep ( 5000);     // make this thread alive five seconds 
        } the catch (Exception E) {
        }
        p.destroy ();     // end this process 
    }
};

 

Guess you like

Origin www.cnblogs.com/tszr/p/12152889.html