黎明前的黑暗
一切不行都是人不行
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            Task t1 = new Task(() =>
            {
                for (int i = 0; i < 10; i++)
                {
                    System.Threading.Thread.Sleep(100);
                    Console.WriteLine("TASK1 do something" + i);
                }
            });

            Task t2 = new Task(() =>
            {
                for (int i = 0; i < 10; i++)
                {
                    System.Threading.Thread.Sleep(200);
                    Console.WriteLine("TASK2 do something" + i);
                }
            });

            Task t3 = new Task(() =>
            {
                for (int i = 0; i < 10; i++)
                {
                    System.Threading.Thread.Sleep(200);
                    Console.WriteLine("TASK3 do something" + i);
                }
            });
            t1.Start();
            t2.Start();
            t3.Start();
            Task.WaitAll(t1, t2, t3);
            Console.WriteLine("over");
            Console.ReadLine();
        }
    }
}
posted on 2015-06-05 11:14  无厘头的小情绪  阅读(156)  评论(0编辑  收藏  举报