zoukankan      html  css  js  c++  java
  • 单例模式

    单例模式(Singleton):保证一个类仅有一个实例,并提供一个访问它的全局访问点

    public abstract class Singleton<T> where T:new ()
    {
    private static T _instance;
    private static readonly object obj=new object();

    public static T Instance
    {
    get
    {
    if (_instance == null)
    {
    lock (obj)
    {
    if (_instance == null)
    {
    _instance=new T();
    }
    }
    }
    return _instance;
    }
    }

    }

  • 相关阅读:
    C# 应用
    WPF 应用
    WPF 应用
    WPF 应用
    WPF 基础
    WPF 基础
    WPF 应用
    WPF 应用
    下厨房
    买苹果
  • 原文地址:https://www.cnblogs.com/cherious/p/6417336.html
Copyright © 2011-2022 走看看