Confusion about the lock statement in C#

后端 未结 6 1260
孤独总比滥情好
孤独总比滥情好 2020-12-05 18:27

This is from MSDN: The lock keyword ensures that one thread does not enter a critical section of code while another thread is in the critical sectio

6条回答
  •  -上瘾入骨i
    2020-12-05 19:24

    No it means that another thread wont enter THE critical section protected by this lock statement.

    The Critical section is only defined by the programmer, and in this case, you could replace it by : the section protected by a lock

    So translation : The lock keyword ensures that one thread does not enter a section of code protected by a lock while another thread is in this section of code (protected by a lock )

提交回复
热议问题