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();
            }
        }
    }
  • 相关阅读:
    短信发送流程
    aidl
    tail
    RIL层传输的方式就是socket
    adb s <设备> <命令>
    Shell
    你好,色彩 android:background="@color/white" [create file color.xml at res/values/]
    [C#]在C#中使用NUnit进行单元测试
    [ASP.NEt] IE6布署NET网站时,Oracle 抛出异常
    [ASP.NET]如何Response.Redirect新的页面到指定的框架中(原创)
  • 原文地址:https://www.cnblogs.com/mcqueen/p/4023768.html
Copyright © 2011-2022 走看看