Home  >  Article  >  Backend Development  >  C# program to display thread priority

C# program to display thread priority

王林
王林forward
2023-08-31 17:17:021168browse

C# program to display thread priority

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

Example

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

Output

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete
Previous article:Abstract keywords in C#Next article:Abstract keywords in C#