> ## Documentation Index
> Fetch the complete documentation index at: https://ancplua.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AL0011 - Avoid lock keyword on non-Lock types

> The lock keyword on object/non-Lock types should be replaced with the Lock class

Source: [AL0011LockKeywordAnalyzer.cs](https://github.com/ANcpLua/ANcpLua.Analyzers/blob/main/src/ANcpLua.Analyzers/Analyzers/AL0011LockKeywordAnalyzer.cs)

## Description

The lock keyword on object/non-Lock types should be replaced with the Lock class from System.Threading.

## Bad Code

```csharp theme={null}
private object _syncRoot = new();
lock (_syncRoot) { }
```

## Good Code

```csharp theme={null}
private Lock _syncRoot = new();
lock (_syncRoot) { }
```

## Properties

* **Category**: Threading
* **Severity**: Warning
* **Enabled by default**: True
* **Code fix available**: True

## Configuration

```editorconfig theme={null}
dotnet_diagnostic.AL0011.severity = warning
```
