启用一个线程的Start方法

启动一个线程是调用 start() 方法,new一个ThreadStart class, 然后,把ThradStart class对象传给Thread类,Thread类start()

View Code
   public class ThreadWork
    {
        public static void DoWork()
        {
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("Working thread..{0}", i);
                Thread.Sleep(100);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            ThreadStart myStart = new ThreadStart(ThreadWork.DoWork);
            Thread myThread = new Thread(myStart);

            //启用一个Thread
            myThread.Start();
        }
    }

 

posted @ 2013-04-27 22:10  Binyao  阅读(260)  评论(0编辑  收藏  举报