Skip to main content

Synchronization & Advanced Patterns

Mutual Exclusion with Lock

0:00
LearnStep 1/4

Race Conditions in Async

The Problem: Shared State

Even in single-threaded async code, race conditions can occur when modifying shared state:

python

What Happened?

text

Both tasks read the same value before either wrote back!