我想了解LINQ如何處理線程。以下代碼會生成ThreadStateException「線程尚未啓動」。爲什麼會發生?LINQ枚舉線程
var threads = Enumerable.Range(0, 50).Select(x =>
{
Thread thread = new Thread(Method);
thread.Name = x.ToString();
return thread;
});
foreach (var thread in threads)
{
thread.Start();
}
foreach (var thread in threads)
{
thread.Join();
}
Console.WriteLine(j);