Interviews2 answers
Why to use lock statement in C#?
2 Answers
In case a multiple threads is executed at-a-time the application may be crashed.
"Lock" does a beautiful job which is "Make to execute one thread at-a-time" remaining will be waiting till that processing thread complete its work.
Ayappan AlagesanPosted Feb 11, 2017, 8:12 PM EST
Lock will make sure one thread will not intercept the other thread which is running the part of code. So lock statement will make the thread wait, block till the object is being released
Vivek KumarPosted Feb 8, 2016, 8:22 AM EST

