阅读475 返回首页    go 阿里云 go 技术社区[云栖]


java.lang.Runtime中的单例模式

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

    public static Runtime getRuntime() { 
           return currentRuntime;
    }

    private Runtime() { }

}


这是典型的饿汉模式。懒汉和饿汉各有应用场景,请看文章:https://blog.csdn.net/woshixuye/article/details/10020709?locationNum=2

最后更新:2017-04-03 12:56:06

  上一篇:go C++ Virtual详解
  下一篇:go 【Android-UI】包含多个子View时触发父节点的焦点事件