Skip to main content
The threading module provides thread-based parallelism for concurrent execution.

Module Import

Creating Threads

Basic Thread Creation

Thread with Class

Synchronization

Lock - Mutual Exclusion

Event - Thread Signaling

Semaphore - Limited Access

Thread Pool

Use threading for I/O-bound tasks where threads spend time waiting.
Python’s Global Interpreter Lock (GIL) prevents true parallel execution of CPU-bound code. Use multiprocessing for CPU-bound tasks.

asyncio

Asynchronous I/O

multiprocessing

Process-based parallelism

concurrent.futures

High-level concurrency