Beispiel #1
0
        public test2Thread()
        {
            Console.WriteLine("Main thread in");
            List <Thread> threads = new List <Thread>();

            for (int i = 0; i < 5; i++)
            {
                threads.Add(ThreadFactory.getThread(new ThreadStart(addCount)));
            }
            for (int i = 0; i < threads.Count; i++)
            {
                threads[i].Start();
            }
            Thread.Sleep(1000);
            Console.WriteLine("Main thread out");
        }
Beispiel #2
0
 public testThread()
 {
     try
     {
         Console.WriteLine("Main thread start");
         Thread thread1 = ThreadFactory.getParameterizedThread(new ParameterizedThreadStart(this.printThis));
         thread1.Start(new String("Hello world"));
         Thread thread2 = ThreadFactory.getThread(new ThreadStart(this.printSomething));
         thread2.Start();
         Thread.Sleep(1000);
         Console.WriteLine("Main thread end out");
     }
     catch (AggregateException es)
     {
         Console.WriteLine(es);
     }
     Console.Read();
 }