小白菜系列之多线程(1)——创建线程

C# 中创建线程

C# 使用 Thread 类创建线程:

static void PrintNumbers(int start, int end) {
    Console.WriteLine("Starting...");
    for (int i = start; i <= end; i++) {
        Console.WriteLine(i);
    }
}

static void Main(string[] args) {
    Thread t = new Thread(() => PrintNumbers(3, 6));
    t.Start();
    PrintNumbers(3, 6);
    Console.ReadLine();
}

So easy!

posted @ 2015-11-30 20:34  nianhua11  阅读(148)  评论(0编辑  收藏  举报