C# program to print the priority of current thread

Priority of current thread in C#: Here, we are going to learn how to print the priority of current thread in C#?
Submitted by Nidhi, on August 16, 2020

As we know, there are the following types of priorities of a thread in C#.

  1. Zero
  2. Normal
  3. Below Normal
  4. Above Normal
  5. Highest

Here we print the priority of current thread on the console screen.

Program:

/*
 *  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 »


ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.