The Java code of the singleton pattern embodies the runtime class (the class provided by the JDK)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.