threading

Stdlib — ConcurrencyPython 2.0+Advanced

Thread-based parallelism: Thread, Lock, RLock, Semaphore, Event, Condition

Quick Info

Documentation
Official Docs
Python Version
2.0+
Dependencies
None — Python Standard Library
Install
Included with Python

Learn by Difficulty

Quick Example

python
import threading

results = []

def worker(n):
    results.append(n * n)

threads = [threading.Thread(target=worker, args=(i,)) for i in range(5)]
for t in threads: t.start()
for t in threads: t.join()
print(f"Results: {sorted(results)}")

The threading module is part of Python's standard library. Thread-based parallelism: Thread, Lock, RLock, Semaphore, Event, Condition.

Try in Playground

Tags

stdlibconcurrencyparallelismthreadGIL

Related Items