Lock

Noun · Development

Definitions

  1. A synchronization primitive that enforces mutual exclusion — only one thread can hold the lock at a time, and all other threads that attempt to acquire it will block (or spin) until it is released. Common variants include mutexes, read-write locks, and spinlocks.

    In plain English: A mechanism that lets only one thread access a shared resource at a time, making others wait their turn to prevent data corruption.

    Example: "We wrapped the counter increment in a lock, but now the threads spend more time waiting for the lock than doing actual work."

Related Terms