有趣的多线程编程(1)——一个简单的例子
有趣的多线程编程(1)——一个简单的例子 //------------------------
, i); Thread.Sleep(1000); } } , i); Thread.Sleep(500); } }}
结果:Main thread: 0Other thread: 0Other thread: 1Main thread: 1Other thread: 2Other thread: 3Main thread: 2Other thread: 4Other thread: 5Main thread: 3Other thread: 6Other thread: 7Main thread: 4Other thread: 8Other thread: 9
//UsingDelegate.cs
------------------------------------
{
{
Counter foo =
ThreadStart job =
Thread thread =
thread.Start();
{
Console.WriteLine (, i);
Thread.Sleep(1000);
}
}
}
{
{
, i);
Thread.Sleep(500);
}
}
}