C# Program to display priority of Thread


To show the priority of the thread in C#, use the Priority property.

Firstly, use the currentThread property to display information about a thread −

Thread thread = Thread.CurrentThread;

Now use the thread.Priority property to display the priority of the thread −

thread.Priority

Example

Let us see the complete code to show the thread’s priority in C#.

Live Demo

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();
      }
   }
}

Output

Thread Priority = Normal

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 19-Jun-2020

227 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements