multithreading
Multithreading is a concurrency model in which a single process runs multiple threads of execution that share the same memory space:
Each thread keeps its own program counter and call stack, but every thread in the process reads and writes the same heap and global data. The operating system’s scheduler interleaves the threads on a single core, switching rapidly between them, or runs them at the same time across several cores. Multithreading can therefore deliver concurrency, parallelism, or both.
Programs turn to multithreading to stay responsive while waiting on input and output, and to spread computation across cores. Shared memory makes communication between threads cheap, but it also invites race conditions when two threads update the same data at once.
Code that behaves correctly under any interleaving is called thread-safe, and multithreaded programs reach that state by guarding shared data with synchronization primitives such as mutexes and semaphores. Creating a fresh thread for every task is costly, so work is often handed to a fixed group of reusable threads called a thread pool.
In Python, the threading module exposes this model, although CPython’s global interpreter lock (GIL) has long allowed only one thread to execute Python bytecode at a time. Free-threaded builds, introduced as an experimental option in Python 3.13 and officially supported in Python 3.14, relax that limit.
Related Resources
Tutorial
An Intro to Threading in Python
In this intermediate-level tutorial, you'll learn how to use threading in your Python programs. You'll see how to create threads, how to coordinate and synchronize them, and how to handle common problems that arise in threading.
For additional information on related topics, take a look at the following resources:
- Python Thread Safety: Using a Lock and Other Techniques (Tutorial)
- Threading in Python (Course)
- Speed Up Your Python Program With Concurrency (Tutorial)
- Python 3.13: Free Threading and a JIT Compiler (Tutorial)
- Python Threading (Quiz)
- Thread Safety in Python: Locks and Other Techniques (Course)
- Python Thread Safety: Using a Lock and Other Techniques (Quiz)
- Speed Up Python With Concurrency (Course)
- Python Concurrency (Quiz)
- Python 3.13: Free Threading and a JIT Compiler (Quiz)
By Martin Breuss • Updated Sept. 5, 2026