Lock Statement
A statement that allows only one thread at a time into a protected block for the same lock object.
What does Lock Statement do in C#?
Lock Statement — A statement that allows only one thread at a time into a protected block for the same lock object.
class Counter
{
readonly object gate = new();
int value;
void Increment()
{
lock (gate)
{
value++;
}
}
}
Level: Master · More C# terms at this level
Updated