Home »
.Net »
C# Programs
C# - How to Print the Priority of Current Thread?
Here, we are going to learn how to print the priority of current thread in C#?
By Nidhi Last updated : March 29, 2023
Types of Thread Priorities
There are the following types of priorities of a thread in C#,
- Zero
- Normal
- Below Normal
- Above Normal
- Highest
Here we print the priority of current thread on the console screen.
C# program to print the priority of current thread
/*
* Program to print the priority of current thread in C#.
*/
using System;
using System.Threading;
class ThreadEx {
static void Main() {
Thread Thr = Thread.CurrentThread;
Thr.Name = "MyThread";
Console.WriteLine("Information about current thread:");
Console.WriteLine("\tName of the thread: " + Thr.Name);
Console.WriteLine("\tPriority of thread: " + Thr.Priority);
}
}
Output
Information about current thread:
Name of the thread: MyThread
Priority of thread: Normal
Press any key to continue . . .
Explanation
In the above program, we created a class ThreadEx that contains the Main() method. Here we created the thread Thr using Thread.CurrentThread property. Then we assigned the name of the thread and then print name and priority of thread on the console screen.
C# Thread Programs »