Skip to main content

Synchronization & Advanced Patterns

Limiting Concurrency with Semaphore

0:00
LearnStep 1/4

What is a Semaphore?

Semaphore: Limited Access

While a Lock allows only ONE holder, a Semaphore allows up to N:

python

Semaphore vs Lock

LockSemaphore
Max 1 holderMax N holders
Binary (yes/no)Counting (available slots)
Mutual exclusionResource limiting