/// <summary>
        /// The main entry point for the application.
        /// </summary>
        static int Main(string[] args)
        {
            int rValue = 0;

            Thread[]   threads = new Thread[100];
            ThreadSafe tsi     = new ThreadSafe(threads.Length);

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i]      = new Thread(new ThreadStart(tsi.ChangeValue));
                threads[i].Name = i.ToString();
                threads[i].Start();
            }

            tsi.Signal();

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i].Join();
            }

            if (tsi.Success)
            {
                rValue = 100;
            }
            Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
            return(rValue);
        }
示例#2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>

        static int Main(string[] args)
        {
            int rValue = 0;

            Thread[]   threads = new Thread[100];
            ThreadSafe tsi     = new ThreadSafe();

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i] = new Thread(new ThreadStart(tsi.ThreadWorker));
                threads[i].Start();
            }

            tsi.Signal();

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i].Join();
            }

            if (tsi.Total == tsi.Expected * threads.Length)
            {
                rValue = 100;
            }
            Console.WriteLine("Test Expected {0}, but found {1}", tsi.Expected * threads.Length, tsi.Total);
            Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
            return(rValue);
        }
示例#3
0
        static int Main(string[] args)
        {
            int rValue = 0;

            Thread[]   threads = new Thread[100];
            ThreadSafe tsi     = new ThreadSafe();

            for (int i = 0; i < threads.Length - 1; i++)
            {
                if (i % 2 == 0)
                {
                    threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerA));
                }
                else
                {
                    threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerB));
                }
                threads[i].Start();
            }
            threads[threads.Length - 1] = new Thread(new ThreadStart(tsi.ThreadChecker));
            threads[threads.Length - 1].Start();
            tsi.Signal();

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i].Join();
            }

            if (tsi.Pass)
            {
                rValue = 100;
            }
            Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
            return(rValue);
        }
示例#4
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>        
        static int Main(string[] args)
        {
            int rValue = 0;
            Thread[] threads = new Thread[100];
            ThreadSafe tsi = new ThreadSafe();
            for (int i = 0; i < threads.Length - 1; i++)
            {
                if (i % 2 == 0)
                    threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerA));
                else
                    threads[i] = new Thread(new ThreadStart(tsi.ThreadWorkerB));
                threads[i].Start();
            }
            threads[threads.Length - 1] = new Thread(new ThreadStart(tsi.ThreadChecker));
            threads[threads.Length - 1].Start();
            tsi.Signal();

            for (int i = 0; i < threads.Length; i++)
                threads[i].Join();

            if (tsi.Pass)
                rValue = 100;
            Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
            return rValue;
        }
示例#5
0
		static int Main(string[] args)
		{
			int loops = 100;
			int rValue = 0;
			if(args.Length == 1)
				loops = Int32.Parse(args[0]);
			float valuetoadd = 10.12345F;
			Thread[] threads = new Thread[100];
			ThreadSafe tsi = new ThreadSafe(100,valuetoadd);
			for (int i = 0; i < threads.Length; i++)
			{
				threads[i] = new Thread(new ThreadStart(tsi.ThreadWorker));
				threads[i].Start();
			}
			
			tsi.Signal();

			for(int i=0;i<threads.Length;i++)
				threads[i].Join();
			float expected = 0.0F;
			for(int i=0;i<threads.Length*loops;i++)
				expected = (float)(expected + valuetoadd);
			if(tsi.Total == expected)
				rValue = 100;
			Console.WriteLine("Expected: "+expected);
			Console.WriteLine("Actual  : "+tsi.Total);
			Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
			return rValue;
		}
        static int Main(string[] args)
        {
            int loops  = 100;
            int rValue = 0;

            if (args.Length == 1)
            {
                loops = Int32.Parse(args[0]);
            }
            float valuetoadd = 10.12345F;

            Thread[]   threads = new Thread[100];
            ThreadSafe tsi     = new ThreadSafe(100, valuetoadd);

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i] = new Thread(new ThreadStart(tsi.ThreadWorker));
                threads[i].Start();
            }

            tsi.Signal();

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i].Join();
            }
            float expected = 0.0F;

            for (int i = 0; i < threads.Length * loops; i++)
            {
                expected = (float)(expected + valuetoadd);
            }
            if (tsi.Total == expected)
            {
                rValue = 100;
            }
            Console.WriteLine("Expected: " + expected);
            Console.WriteLine("Actual  : " + tsi.Total);
            Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
            return(rValue);
        }
示例#7
0
		static int Main(string[] args)
		{
			int rValue = 0;
			Thread[] threads = new Thread[100];
			ThreadSafe tsi = new ThreadSafe(threads.Length);
			for (int i = 0; i < threads.Length; i++)
			{
				threads[i] = new Thread(new ThreadStart(tsi.ChangeValue));
				threads[i].Name = i.ToString();
				threads[i].Start();
			}
			
			tsi.Signal();

			for(int i=0;i<threads.Length;i++)
				threads[i].Join();

			if(tsi.Success)
				rValue = 100;
			Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
			return rValue;
		}
示例#8
0
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		
		static int Main(string[] args)
		{
			int rValue = 0;
			Thread[] threads = new Thread[100];
			ThreadSafe tsi = new ThreadSafe();
			for (int i = 0; i < threads.Length; i++)
			{
				threads[i] = new Thread(new ThreadStart(tsi.ThreadWorker));
				threads[i].Start();
			}
			
			tsi.Signal();

			for(int i=0;i<threads.Length;i++)
				threads[i].Join();

			if(tsi.Total == tsi.Expected * threads.Length)
				rValue = 100;
			Console.WriteLine("Test Expected {0}, but found {1}", tsi.Expected * threads.Length, tsi.Total);
			Console.WriteLine("Test {0}", rValue == 100 ? "Passed" : "Failed");
			return rValue;
		}