Imports System.Threading
public class Test
Shared Dim obj As New someClass()
public Shared Sub Main
Dim thread1 As New Thread(AddressOf method1)
Dim thread2 As New Thread(AddressOf method2)
thread1.Start()
thread2.Start()
End Sub
Private Shared Sub method1()
SyncLock (obj)
Dim i As Integer
For i = 0 To 5
obj.someData += i
Console.WriteLine(obj.someData)
Next
End SyncLock
End Sub
Private Shared Sub method2()
SyncLock (obj)
Dim i As Integer
For i = 0 To 5
obj.someData += i
Console.WriteLine(obj.someData)
Next
End SyncLock
End Sub
End class
Public Class someClass
Public Shared someData As Integer
End Class
0
1
3
6
10
15
15
16
18
21
25
30