public static void TestSingleton() { //MySingleton a = MySingleton.Get(); //a.Testref(); for (int i = 0; i < 10; i++) { Task.Run(() => { Console.WriteLine(MySingleton.Get().ID); }); } }
static public MySingleton Get() { if (ins == null) { lock (locker) { if (ins == null) { ins = new MySingleton(); } } } return(ins); }