private static void Main(string[] args)
{
for (int i = 0; i < 1000; i++)
{
Task.Factory.StartNew(() =>
{
Thread.Sleep(1000);
Console.WriteLine("hej");
Thread.Sleep(10000);
});
}
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
为什么这段代码在一秒钟后不能打印1000次"hej"?为什么Thread.Sleep(10000)会对代码行为产生影响?