You don’t control who else locks this.
Fix
private readonly object _sync = new();
lock (_sync) { }
Why
Encapsulation matters in threading.
Daily micro-tips for C#, SQL, performance, and scalable backend engineering.
You don’t control who else locks this.
Fix
private readonly object _sync = new();
lock (_sync) { }
Why
Encapsulation matters in threading.