线程的创建

class Program {
    static void Main(string[] args) {

        // 使用无参数委托ThreadStart
        Thread t = new Thread(wucan);
        t.Start();

        // 使用带参数委托ParameterizedThreadStart
        Thread t2 = new Thread(youcan);
        t2.Start("chuanru");

        t2.Join();// 等待线程t2完成。

        Console.WriteLine("Thread t2 已经执行完成");
        Console.ReadKey();
    }

    static void wucan() {
        Console.WriteLine("wucan!");
    }

    static void GoWithParam(object msg) {
        Console.WriteLine("msg:" + msg);
        Thread.Sleep(1000);// 模拟耗时操作
    }
}
posted @ 2017-08-04 16:25  任飞儿  阅读(142)  评论(0编辑  收藏  举报