ADVERTISEMENT
ADVERTISEMENT

VB.Net program to print the priority of the current thread

Here, we are going to learn how to print the priority of the current thread in VB.Net?
Submitted by Nidhi, on January 04, 2021

To solve the above problem, we need to use the Priority property of the Thread class, it will return the priority of the current thread.

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

Program/Source Code:

The source code to print the priority of the current thread is given below. The given program is compiled and executed successfully.

'Vb.Net program to print the priority 
'of the current thread.

Imports System.Threading

Module Module1
    Sub Main()
        Dim t As Thread
        t = Thread.CurrentThread
        t.Name = "MyNewThread"

        Console.WriteLine("Thread information:")
        Console.WriteLine(vbTab & "Name of the thread: " + t.Name)
        Console.WriteLine(vbTab & "Priority of thread: {0}", t.Priority)
    End Sub
End Module

Output:

Thread information:
        Name of the thread: MyNewThread
        Priority of thread: Normal
Press any key to continue . . .

Explanation:

In the above program, we imported the System.Threading namespace to implement multithreading in the program. After that, we created a module Module1. The Module1 contains Main() function.

The Main() is the entry point for the program, we created the reference of Thread class and assigned the object of the current thread using the CurrentThread property. After that, we used the Priority property of the Thread class and print the priority of the current thread on the console screen.

VB.Net Threading Programs »



ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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.