Process vs Thread — What's the Difference?
A process is an independent running program with its own memory space; a thread is a smaller unit of execution within a process that shares that process's memory with other threads in the same process.
Published October 4, 2026
A process is an independent running program with its own memory; a thread is a unit of execution inside a process that shares that memory with other threads. Threads are lighter but need careful synchronisation.
The concept
Each process has a private address space, so one crashing process does not corrupt another. Communicating between processes needs IPC such as pipes or sockets.
Threads in a process share the heap and globals, which makes sharing data easy and race conditions possible. Creating a thread is cheaper than starting a process.
Memory layout
Practical examples
Threads sharing data (needs a lock)
import threading
count = 0; lock = threading.Lock()
def work():
global count
for _ in range(100000):
with lock: count += 1
ts = [threading.Thread(target=work) for _ in range(4)]
[t.start() for t in ts]; [t.join() for t in ts]Separate processes
from multiprocessing import Process
p = Process(target=print, args=('hi from child',)); p.start(); p.join()See them
ps aux | head
ps -T -p <pid> # threads of a processCommon mistakes
- Sharing mutable data between threads without locks.
- Spawning thousands of processes instead of a pool.
- Assuming threads speed up CPU work in Python (GIL).
Key takeaways
- Process = isolated, thread = shared memory.
- Threads are cheaper, processes safer.
- Synchronise shared state.
FAQ
What is context switching?
The OS saving one thread or process's state and running another; processes cost more.
What is a thread pool?
A fixed set of reusable threads that run queued tasks.