using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace ConsoleApplication1 { class Mythread { public int count; string thrdName; public Mythread(string name) { count = 0; thrdName = name; } public void run() { Console.WriteLine(thrdName + " starting."); do { Thread.Sleep(500); Console.WriteLine("in " + thrdName + ",count is " + count); count++; } while (count < 10); Console.WriteLine(thrdName + " terminating."); } } class Program { static void Main(string[] args) { Console.WriteLine("Main thread starting."); Mythread mt = new Mythread("linbo 1"); Thread newThrd = new Thread(new ThreadStart(mt.run)); newThrd.Start(); do { Console.Write("."); Thread.Sleep(100); } while (mt.count != 10); Console.WriteLine("Main thread ending."); Console.Read(); } } }