Пример #1
0
        public static void TestSingleton()
        {
            //MySingleton a = MySingleton.Get();

            //a.Testref();

            for (int i = 0; i < 10; i++)
            {
                Task.Run(() =>
                {
                    Console.WriteLine(MySingleton.Get().ID);
                });
            }
        }
Пример #2
0
        static public MySingleton Get()
        {
            if (ins == null)
            {
                lock (locker)
                {
                    if (ins == null)
                    {
                        ins = new MySingleton();
                    }
                }
            }

            return(ins);
        }