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

# AL0060 - Avoid lock on string

> String interning creates cross-assembly synchronization, risking deadlocks

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

## Description

Interned strings are shared across the entire AppDomain. Locking on a string literal can deadlock with unrelated code.

## Bad Code

```csharp theme={null}
public void Update()
{
    lock ("myLock") { _count++; }
}
```

## Good Code

```csharp theme={null}
private readonly Lock _syncRoot = new();
public void Update()
{
    lock (_syncRoot) { _count++; }
}
```

## Properties

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

## Configuration

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