单例模式

xiaoxiao2025-03-06  12

 public class 单例模式 {         private static 单例模式 _share;         private static Object obj = new Object();         private 单例模式() {}         public static 单例模式 Share单例模式() {             if (_share == null)             {                 lock (obj)                 {                     if (_share == null)                     {                         _share = new 单例模式();                     }                 }             }             return _share;         }     }     public class 单例模式1     {         private static 单例模式1 _share;         static 单例模式1() {             _share = new 单例模式1();         }         public static 单例模式1 Share() {             return _share;         } } 

转载请注明原文地址: https://www.6miu.com/read-5025645.html

最新回复(0)