Console.WriteLine("Thread " + ((string)str).ToString()); })); } for (int i = 0; i < 5; i++) Pool[i].Start(i.ToString()); Console.WriteLine("Thread Start!"); for (int i = 0; i < 5; i++) Pool[i].Join(); Console.WriteLine("Thread Done!"); Console.ReadLine(); Li...
For the need of a lock, see "The System.Random class and thread safety" in the Random class topic. 備註 呼叫StartNew 的功能相當於使用其中一個建構函式建立 Task ,然後呼叫 Start 方法來排程執行。 從.NET Framework 4.5 開始,您可以使用 Run 方法搭配 Action 物件,以快速呼叫 StartNew 預設參數。