zoukankan      html  css  js  c++  java
  • C# 设计模式

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace DBImportTool.Sgile
    {
        //第一种单例模式Demo
        public class A
        {
            private volatile static A _instance = null;
            private static readonly object lockHelper = new object();
            private A() { }
            public static A CreateInstance()
            {
                // 判断如果没有实例过,则进行实例化创建.
                
    // 瞬间触发量不高的网站,不需要此判断步骤.
                if (_instance == null)
                {
                    //锁机制.防止重复实例化.
                    lock (lockHelper)
                    {
                        if (_instance == null)
                        {
                            _instance = new A();
                        }
                    }
                }
                return _instance;
            }
        }

        //第二种单例模式Demo
        public sealed class B
        {
     
            B() { }
            public static B GetInstance()
            {
                return B1.b;
            }
            class B1
            {
                static B1()
                {
                }
                internal static readonly B b = new B();
            }
        }
    }
  • 相关阅读:
    viewpoint vw适配 兼容方案
    函数参数默认值
    vue v-bind 的prop属性
    vue 全局错误处理 errorHandler
    Python模块学习
    频谱共享---小记
    LTE的信道
    PLMN(公共陆地移动网络)
    单元测试框架GoogleTest
    OpenRAN是什么
  • 原文地址:https://www.cnblogs.com/mcqueen/p/4023768.html
Copyright © 2011-2022 走看看