Q:

C# program to print the priority of current thread

0

C# program to print the priority of current thread

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now