Halcom 发表于 2023-4-19 21:29:58

类的实例化

         private static readonly object _lockObj = new object();

      private static halcomcn _instance;

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

页: [1]
查看完整版本: 类的实例化