AI engineering glossary · Python advanced

What is lock?

Lock (also called Mutex): A synchronisation tool that lets only one thread or task at a time enter a critical section of code. It prevents corrupted shared data but, if misused, can cause deadlocks or slowdowns.

Level: advancedTopic: Python advanced

Lock: an example

with lock: counter += 1 ensures two threads never update counter simultaneously.

Related terms

More Python advanced terms

Where you learn it

Lock is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.