To display the priority of a thread in C#, use the Priority property.
First, use the currentThread property to display information about the thread -
Thread thread = Thread.CurrentThread;
Now use the thread.Priority property to display the thread's priority -
thread.Priority
Let us look at the complete code to display thread priority in C#.
Real-time demonstration
using System; using System.Threading; namespace Demo { class MyClass { static void Main(string[] args) { Thread thread = Thread.CurrentThread; thread.Name = "My Thread"; Console.WriteLine("Thread Priority = {0}", thread.Priority); Console.ReadKey(); } } }
Thread Priority = Normal
The above is the detailed content of C# program to display thread priority. For more information, please follow other related articles on the PHP Chinese website!