Search⌘ K
AI Features

Threads vs. Processes on Linux

Explore how threads and processes work in Python on Linux, including their memory management and execution. Learn why threading may slow down code due to the Global Interpreter Lock and how multiprocessing offers a solution for parallel execution in independent tasks.

In this lesson, we’ll create multithreaded processes with a focus on Linux, as Python is closely tied with Linux development. The theory is the same for Windows as well, although the underlying implementation differs.

Processes

Any program that runs in Linux is a process. Each process has its memory, stack, and access to shared peripherals. As far as each process is concerned, it has the whole computer to itself. Additionally, if you’ve done any Windows programming (programming the Microsoft Windows API), you’ll find some differences in terminology. Microsoft has a few special terms it uses for its processes.

So how do multiple processes run at the same time? That’s the job of the operating system. It ensures that each ...