C Sharp Main Thread

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

C# Main Thread Example

The first thread which is created inside a process is called Main thread. It starts first and ends at last.

Let's see an example of Main thread in C#.

 
  1. using System;  
  2. using System.Threading;  
  3. public class ThreadExample  
  4. {  
  5.     public static void Main(string[] args)  
  6.     {  
  7.         Thread t = Thread.CurrentThread;  
  8.         t.Name = "MainThread";  
  9.         Console.WriteLine(t.Name);  
  10.     }  
  11. }  

Output:

MainThread