# 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.

```csharp
class Counter
{
    readonly object gate = new();
    int value;

    void Increment()
    {
        lock (gate)
        {
            value++;
        }
    }
}
```

Level: Master · [More C# terms at this level](https://www.ask-codey.com/glossary/subjects/c-sharp/master)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/lock-statement
