A lock is a way for software to temporarily limit access to something shared. It helps prevent two tasks from changing the same information at once in a way that causes a mistake.

Imagine one person borrowing a library book while another waits to edit its catalog card. Once the first person is done, the next can make their change.

Locks should be released when the work is finished. If a lock is held too long, other tasks may have to wait, making the app feel stuck.