The source code section of the runtime class is as follows:
/*runtime part of the source code, to others bragging small capital *public class runtime{* Private Runtime () {} * private static runtime currentruntime = new Runt IME (); * public static Runtime GetRuntime () {* return currentruntime; *} *} * *
//design pattern (Java code in singleton mode embodies runtime Class)
/*
* Runtime: This is the JDK provided by the Han-style singleton model, the JDK is used in the Han style, we develop the use of the Han style (interview when the interviewer asked you to write a singleton mode that you want to write lazy, because he will test you is the line of multi-pass security issues)
* Runtime: Each Java application has a runtime class instance that enables the application to connect to the environment in which it is running.
* One method in runtime exec (String command)
* Runtime is a class of singleton schemas provided by the JDK Help documentation, and this class provides a way for Exec to invoke DOS commands
*/
Package Creation _ Singleton Mode _ in JDK application Runtime;import Java.io.ioexception;public class Runtimemain {public static void main (string[] args) throws Ioexception{runtime Runtime = Runtime.getruntime ();//runtime.exec (command);//runtime.exec ("winmine"); /open Minesweeper, as if not wrong? This command name Runtime.exec ("Notepad"); Runtime.exec ("Calc"); Runtime.exec ("Shutdown-s-T 10000");// The system shuts down after 10,000 seconds runtime.exec ("shutdown-a");//Cancel Shutdown}}
The Java code of the singleton pattern embodies the runtime class (the class provided by the JDK)