Ejemplo n.º 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);
                });
            }
        }
Ejemplo n.º 2
0
        static public MySingleton Get()
        {
            if (ins == null)
            {
                lock (locker)
                {
                    if (ins == null)
                    {
                        ins = new MySingleton();
                    }
                }
            }

            return(ins);
        }