In this article you can see how thread works one by one in an application of VB.NET
• 3550 Download Files:

Multithreading is the ability to do several things at a time. A lengthy task is divided into short segments , this segments called thread. In multithreading the times gets divided by the computer into parts and when a new thread starts, that thread gets a portion of divided time.

Following code represent how to deposit, check and update the customer account.

Imports System
Public Balance As Integer = 10
Sub Main()
Dim account As Account = New Account()
Dim depositeBalance1 As DepositeBalance = New DepositeBalance(account, 10, "Customer 1")
Dim depositeBalance2 As DepositeBalance = New DepositeBalance(account, 10, "Customer 2")
t1.Start()
t2.Start()
Try
t1.Join()
t2.Join()
Catch e As Exception
Console.Write(e.ToString())
Finally
End Try
End Sub
Public Class Account
Private balanceAmount As Integer
Public Sub Deposite(ByVal amount As Integer, ByVal message As String)
Console.WriteLine(message & "Depositing Amount " & amount)
Console.WriteLine(message & " Checking Previous Balance")
Monitor.Enter(Me)
balanceAmount = getBalance()
Console.WriteLine(message & "Previous Balance in Account " & balanceAmount)
balanceAmount += amount
Console.WriteLine(message & " Updating Balance in Account ")
setBalance(balanceAmount)
Monitor.Exit(Me)
Console.WriteLine(message & " Update Balance " & Balance)

End Sub

Private Function getBalance() As Integer
Try
Catch e As Exception
Console.Write(e.ToString())
Finally
End Try
Return Balance
End Function

Private Sub setBalance(ByVal amount As Integer)
Try
Catch e As Exception
Console.Write(e.ToString())
Finally
End Try
Balance = amount
End Sub
End Class

Public Class DepositeBalance
Private account As Account
Private amount As Integer
Private message As String

Public Sub New(ByRef account As Account, ByVal amount As Integer, ByVal message As String)
MyBase.New()
Me.account = account
Me.amount = amount
Me.message = message
End Sub
Public Sub DepositeAmount()
account.Deposite(amount, message)
End Sub
End Class
End Module

The output shows on windows console application like in below figure. CONCLUSON: You just copy this code and pest in vb.net and debug the application you will see how multithreading works.
{"ft_lang_label":"__label__en","ft_lang_prob":0.53496313,"math_prob":0.4337752,"size":2526,"snap":"2019-43-2019-47","text_gpt3_token_len":610,"char_repetition_ratio":0.16931008,"word_repetition_ratio":0.0877193,"special_character_ratio":0.20783848,"punctuation_ratio":0.11694511,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9518626,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,null,null,null,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-16T08:16:05Z\",\"WARC-Record-ID\":\"<urn:uuid:e9b5e37f-2542-4931-bba5-fd5a88fffcef>\",\"Content-Length\":\"77990\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b0380263-0b9e-4135-9ab2-ed95d2f5f997>\",\"WARC-Concurrent-To\":\"<urn:uuid:7739c409-0007-4042-816d-76a380b92c6c>\",\"WARC-IP-Address\":\"161.47.36.128\",\"WARC-Target-URI\":\"https://www.dotnetheaven.com/article/multithreading-in-vb.net\",\"WARC-Payload-Digest\":\"sha1:HGRUCTIVHRQFO5ZKSI5MXTEOTVMNZJ6C\",\"WARC-Block-Digest\":\"sha1:KCKCFV6Q3KL3XMZZFFLII2SADCTYHHEM\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570986666467.20_warc_CC-MAIN-20191016063833-20191016091333-00228.warc.gz\"}"}