/*
* 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.
Program:
Output:
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.