标题说明了一切,但我提供了一些代码来展示我所要求的内容。
Public Class Class1
Private Object1 As New Class2
Private Sub Test1()
Dim LocalObject1 As New Class3(Object1)
Synclock Object1
'Some code here
End Synclock
End Sub
End Class
Public Class2
'Some custom object type
End Class
Public Class Class3
Private Object2 As Class2
Public Sub New(ObjectIn As Class3)
Object2 = ObjectIn
End Sub
Public Sub DoSomeWork()
Synclock Object2
'Some code here
End Synclock
End Sub
End Class
这两个'Some code here
是否会同时运行(假设它们是在单独的线程上)?