Synclock会锁定对象引用还是对象本身?

时间:2015-09-19 14:40:00

标签: vb.net multithreading synclock

标题说明了一切,但我提供了一些代码来展示我所要求的内容。

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是否会同时运行(假设它们是在单独的线程上)?

0 个答案:

没有答案