码迷,mamicode.com
首页 > 编程语言 > 详细

Java基础 Runtime 用了单例模式中的饿汉式

时间:2017-10-09 12:07:27      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:new   stat   单例   int   creat   ase   模式   private   methods   

礼悟:
           好好学习多思考,尊师重道存感恩。叶见寻根三返一,活水清源藏于零。
           虚怀若谷良心主,皓月当空自在王。愿给最苦行无悔,诚劝且行且珍惜。




    os :windows7 x64
    jdk:jdk-8u131-windows-x64
    ide:Eclipse Oxygen Release (4.7.0)



源码(仅提取出能显示出单例模式-饿汉式 特征性的代码):

/*
 * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package java.lang;

import java.io.*;
import java.util.StringTokenizer;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;

/**
 * Every Java application has a single instance of class
 * <code>Runtime</code> that allows the application to interface with
 * the environment in which the application is running. The current
 * runtime can be obtained from the <code>getRuntime</code> method.
 * <p>
 * An application cannot create its own instance of this class.
 *
 * @author  unascribed
 * @see     java.lang.Runtime#getRuntime()
 * @since   JDK1.0
 */

public class Runtime {
    private static Runtime currentRuntime = new Runtime();

    /**
     * Returns the runtime object associated with the current Java application.
     * Most of the methods of class <code>Runtime</code> are instance
     * methods and must be invoked with respect to the current runtime object.
     *
     * @return  the <code>Runtime</code> object associated with the current
     *          Java application.
     */
    public static Runtime getRuntime() {
        return currentRuntime;
    }

    /** Don‘t let anyone else instantiate this class */
    private Runtime() {}

 

源码分析:

技术分享

 


API:
技术分享

 

 


Java优秀,值得学习。
设计模式中蕴含着极高的智慧,对项目开发有大帮助。
学习资源:itcast和itheima视频库。如果您有公开的资源,可以分享给我的话,用您的资源学习也可以。
博文是观看视频后,融入思考写成的。博文好,是老师讲得好。博文坏,是 给最苦 没认真。

Java基础 Runtime 用了单例模式中的饿汉式

标签:new   stat   单例   int   creat   ase   模式   private   methods   

原文地址:http://www.cnblogs.com/jizuiku/p/7640283.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!