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.
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.