using System; using System.Threading; class MixedNumbers { /// /// The Mixed Up Numbers Program Bishop and Horspool March 2003 /// ============================ /// Prints 20 numbers through two threads. /// Illustrates how threads run independently. /// Thread numberThread; void Go() { new Thread(new ThreadStart(this.LowNums)).Start(); new Thread(new ThreadStart(this.HighNums)).Start(); } static Random r = new Random(); void LowNums() { for (int i=0; i<10; i++) { Console.WriteLine(i + " "); Thread.Sleep(r.Next(100)); } } void HighNums() { for (int i=1000; i<1010; i++) { Console.WriteLine(i + " "); Thread.Sleep(r.Next(100)); } } static void Main() { new MixedNumbers().Go(); } }