VB.Net program to assign the name of a thread

Here, we are going to learn how to assign the name of a thread in VB.Net?
Submitted by Nidhi, on January 04, 2021

Here, we used the Name property Thread class. The Name property is used to set or get the name of the thread.

Program/Source Code:

The source code to assign the name of a thread is given below. The given program is compiled and executed successfully.

'Vb.Net program to assign the name of a thread.

Imports System.Threading

Module Module1
    Sub Main()
        If (Thread.CurrentThread.Name = "") Then
            Thread.CurrentThread.Name = "MyMainThread"
            Console.WriteLine("Name of the thread assigned successfully")
            Console.WriteLine("Name of thread already assigned")
        End If
    End Sub
End Module


Name of the thread assigned successfully
Press any key to continue . . .


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, here we checked if the Name property contains a "null" value then we assigned the MyMainThread name to the current thread otherwise we print "Name of thread already assigned" on the console screen.

VB.Net Threading Programs »


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

© some rights reserved.