C# program to implement Thread class and its properties
Program.cs
Thread t = Thread.CurrentThread;
t.Name = "Main Thread";
Console.WriteLine(t.Name);
Console.WriteLine(t.Priority);
Console.WriteLine(t.IsAlive);
Console.WriteLine(t.CurrentCulture);
Console.WriteLine(t.IsThreadPoolThread);
Console.WriteLine(t.ManagedThreadId);
Console.WriteLine(t.ThreadState);
Explanation:
In the above program, we have created a reference variable of Thread class and stored the CurrentThread in it, and with the help of the reference variable, we have printed the various properties of a thread on the Console. The explanation for each property is given below:

1. The Name property used to set and get the name of current thread (by default value of the Name property is null)
2. The Priority property used to set or get the priority of thread
3. The IsAlive property used to check whether the thread is alive or dead
4. The IsThreadPoolThread property used to check whether a thread belongs to managed thread pool
5. The ManagedThreadId property used to get a unique identifier for the currently managed thread
6. The ThreadState property used to get and set the state of thread
Output
kodingwindow@kw:~/csharp$ dotnet run
Main Thread
Normal
True
en-US
False
1
Running
kodingwindow@kw:~/csharp$ 
Advertisement