C# program to display thread priority

王林
Release: 2023-08-31 17:17:02
forward
1160 people have browsed it

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;
Copy after login

Now use the thread.Priority property to display the thread's priority -

thread.Priority
Copy after login

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

Output

Thread Priority = Normal
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!