ProLesson 9.1Intermediate3 min readUpdated 30 October 2026
Processes vs threads
What a thread is, how it differs from a process, what threads share, and why concurrency makes programs faster and harder.
Your computer runs many things at once: a browser, a music player, an editor. Inside one Java program, many things can happen at once too: a web server handles hundreds of requests at the same time. That's concurrency, and the unit that does the work is a thread.
01Process vs thread
- A process is a running program, with its own memory. Your Java application is one process (one JVM).
- A thread is a path of execution inside a process. A process can have many threads, and they share the same memory (the heap).
text
JVM process
├── Heap (shared by all threads): objects, static fields
├── Thread "main" → its own stack: local variables, method calls
├── Thread "worker-1" → its own stack
└── Thread "worker-2" → its own stack| Process | Thread | |
|---|---|---|
| Memory | Separate | Shared heap, own stack |
| Cost to create | High | Lower (very low for virtual threads) |
| Communication | Pipes, sockets, files | Shared objects (fast, but risky) |
| A crash affects | Only that process | Can bring down the whole process |
Loading the rest of the lesson…