static void Main(string[] args)
{
Parallel.Invoke(Foo, Bar);
}
static void Foo()
{
Console.WriteLine("foo thread {0}",Thread.CurrentThread.ManagedThreadId);
}
static void Bar()
{
Console.WriteLine("bar thread {0}",Thread.CurrentThread.ManagedThreadId);
}
运行结果:
简单方便!!!