コード例 #1
0
        private static void ThreadProc(Object inParam)
        {
            int   sleepTime = (int)inParam;
            test1 t1        = new test1(sleepTime);
            test2 t2        = new test2(sleepTime);

            t1.Display();
            t2.Display();
            t1.DisplayByte("Byte");
            t1.DisplaySByte("SByte");
            t1.DisplayInt("Int");
        }
コード例 #2
0
        static void Main(string[] args)
        {
            int sleepTime = 10;

            if (args.Length != 0)
            {
                sleepTime = int.Parse(args[0]);
            }
            Console.WriteLine("Test profiler");
            //test2 t2 = new test2(sleepTime);


            Thread thr1 = new Thread(ThreadProc);
            Thread thr2 = new Thread(ThreadProc);

            thr1.Start(sleepTime * 2);
            thr2.Start(sleepTime / 2);

            test1 t1 = new test1(sleepTime);

            t1.ThreadPoolMethod();
            test2 t2 = new test2(sleepTime);

            t1.Display();
            t2.Display();
            t1.DisplayByte("Byte");
            t1.DisplaySByte("SByte");
            t1.DisplayInt("Int");
            thr1.Join();
            thr2.Join();
            Thread.Sleep(5000);
            //Console.Read();

            /*
             *  for (int i = 0; i < ThreadNum; i++)
             *  {
             *      var a = new Thread(() => t2.Recursive<int>(10));
             *      a.Start();
             *      _tasks.Add(a);
             *  }
             *  foreach (var s in _tasks)
             *  {
             *      s.Join();
             *  }*/
        }