Qus: When the lock key is used?
Lock keyword ensures that one thread is executing a piece of code at one time. The lock keyword is used to ensure that one thread does not enter a critical section of code while another thread is in that critical section.
The lock material ensures that the text does not include the key portion of a thread code, another thread is in the critical section. When any other text attempts to enter a locked code, it will prevent and block until the material is published