Python Multithreading — Explain Like I'm 5

One Desk, Several Helpers

Imagine a help desk with one manager and several helpers.

Each helper can work on a different customer task:

  • one checks email
  • one downloads a file
  • one waits for printer output

While one helper is waiting, another can keep working. The desk feels faster.

In Python, these helpers are threads.

import threading
import time

def worker(name, delay):
    print(f"{name} started")
    time.sleep(delay)
    print(f"{name} finished")

t1 = threading.Thread(target=worker, args=("A", 2))
t2 = threading.Thread(target=worker, args=("B", 1))

t1.start()
t2.start()

t1.join()
t2.join()

Both jobs run during the same program time window.

Important truth

Threads are very useful when tasks spend time waiting (internet, disk, APIs).

For heavy math, Python threads do not usually speed things up a lot because of a rule called the GIL, which limits how Python bytecode runs at once in one process.

Safe teamwork

If two threads change the same data, they can step on each other. Use a lock to keep shared data safe.

lock = threading.Lock()

A lock is like one key to a storage room: only one helper enters at a time.

One Thing to Remember

Python threads are great for I/O waiting tasks, but shared data needs locks and CPU-heavy work usually needs another approach.

pythonmultithreadingthreadsbeginners

See Also

  • Python Async Await Async/await helps one Python program juggle many waiting jobs at once, like a chef who keeps multiple pots moving without standing still.
  • Python Basics Python is the programming language that reads like plain English — here's why millions of beginners (and experts) choose it first.
  • Python Booleans Make Booleans click with one clear analogy you can reuse whenever Python feels confusing.
  • Python Break Continue Make Break Continue click with one clear analogy you can reuse whenever Python feels confusing.
  • Python Closures See how Python functions can remember private information, even after the outer function has already finished.