コード例 #1
0
        private static void StudentM()
        {
            SingaltonTest3 fromStudentclass = SingaltonTest3.GetInstance;

            fromStudentclass.m1("fromStudentclass");
        }
コード例 #2
0
        //public static void Main()
        //{
        //    //SingaltonTest obj = new SingaltonTest();
        //    //obj.m1("Test1");
        //    //obj.m1("Test2");

        //    //Console.WriteLine("/////////////////////////////////////////");

        //    //SingaltonTest fromEmployeeclass = new SingaltonTest();
        //    //fromEmployeeclass.m1("fromEmployeeclass");

        //    //Console.WriteLine("/////////////////////////////////////////");

        //    //SingaltonTest fromStudentclass = new SingaltonTest();
        //    //fromStudentclass.m1("fromStudentclass");
        //    //it voilates the rule of singalton (in multithreading);
        //    Console.WriteLine("/////////////////////////////////////////");
        //    Parallel.Invoke(
        //        ()=>
        //    EmployeeM(),()=>
        //    StudentM());
        //    Console.WriteLine("/////////////////////////////////////////");
        //    Console.ReadLine();
        //}

        private static void EmployeeM()
        {
            SingaltonTest3 fromEmployeeclass = SingaltonTest3.GetInstance;

            fromEmployeeclass.m1("fromEmployeeclass");
        }