zoukankan      html  css  js  c++  java
  • C# 用Singleton类构建多线程单例模式

    public sealed class Singleton
       {
           private static volatile Singleton uniqueInstance;
     
           private static readonly object locker = new object();
     
           private Singleton()
           {
               var cache = HttpContext.Current.Cache;
           }
           public static Singleton GetInstance()
           {
               if (uniqueInstance == null)
               {
                   lock (locker)
                   {
     
                       if (uniqueInstance == null)
                       {
                           uniqueInstance = new Singleton();
                       }
                   }
               }
               return uniqueInstance;
           }
           public int Number()
           {
               return 1;
           }
           public int Number(int i = 0)
           {
               return i;
           }
       }
  • 相关阅读:
    关于服务器并发量的简单计算
    重温Android和Fragment生命周期
    JVM类加载机制
    设计六大原则总结
    Android Navigation使用
    Android BrocastReceiver解析
    Android LiveData使用
    Android Service解析
    Activity的生命周期和启动模式
    Java四种引用
  • 原文地址:https://www.cnblogs.com/fanying/p/10919151.html
Copyright © 2011-2022 走看看