Define method and Run inside a Thread : Thread Basics « Thread « VB.Net






Define method and Run inside a Thread

Define method and Run inside a Thread
Imports System.Threading

Public Class MainClass

   Public Shared Sub Main()
        Dim A As Thread = New Thread(AddressOf MethodInThread)
        Dim B As Thread = New Thread(AddressOf MethodInThread)
        Dim C As Thread = New Thread(AddressOf MethodInThread)

        A.Name = "A"
        A.Start()

        B.Name = "B"
        B.Start()

        C.Name = "C"
        C.Start()
   End Sub

   Shared Sub MethodInThread()
        Dim O As Thread
        Dim hash As Integer
        O = Thread.CurrentThread

        hash = O.GetHashCode()

        Console.Write("Thread name: {0}", Thread.CurrentThread.Name)
        Console.WriteLine(" Thread hash: {0}", hash.ToString())

    End Sub

End Class 


           
       








Related examples in the same category

1.Start a Thread
2.Put time-consuming Task in ThreadPut time-consuming Task in Thread
3.Shows multiple threads that print at different intervalsShows multiple threads that print at different intervals