Last Updated: May 17, 2026
C# 13 adds a dedicated System.Threading.Lock type for guarding shared state across threads. For two decades, lock (someObject) worked by hijacking the header of any reference type to act as a mutual exclusion primitive, which made every object a potential lock and led to subtle bugs. The new Lock type makes locks a real, named thing in the type system, with a faster code path and clearer intent. This lesson covers what Lock is, why it exists, how the compiler special-cases it inside a lock statement, when to use it over Monitor, SemaphoreSlim, and ReaderWriterLockSlim, and how to migrate existing code without breaking behavior.