C# Thread join TimeSpan
static bool isStop = true; static void Main(string[] args) { Thread t = new Thread(PrintX); t.Start(); isStop = t.Join(TimeSpan.FromSeconds(10)); Console.WriteLine("Finished!"); Console.ReadLine(); } static void PrintX() { for(int i=0;i<Int32.MaxValue;i++) { if(isStop) { Console.WriteLine(i); } } }