using System; using System.Threading; class MainClass { static void MyThreadProc() { Thread.CurrentThread.Name = "TheSecondaryThread"; Thread secondaryThread = Thread.CurrentThread; Console.WriteLine("Name? {0}", secondaryThread.Name); Console.WriteLine("Alive? {0}", secondaryThread.IsAlive); Console.WriteLine("Priority? {0}", secondaryThread.Priority); Console.WriteLine("State? {0}", secondaryThread.ThreadState); Console.WriteLine(); for(int i = 0; i < 1000; i ++) { Console.WriteLine("Value of i is: {0}", i); Thread.Sleep(5); } } [MTAThread] static void Main(string[] args) { Thread secondaryThread = new Thread(new ThreadStart(MyThreadProc)); secondaryThread.Priority = ThreadPriority.Highest; secondaryThread.IsBackground = true; secondaryThread.Start(); } }
Name? TheSecondaryThread Alive? True Priority? Highest State? Background Value of i is: 0