SteelReed

Search

Search posts, questions…

ConcurrencyQuestion 1 / 19

Junior

What is the difference between a process and a thread? And concurrency vs parallelism?

Short answer

A process is a running program with its own memory, isolated by the OS; a thread is a path of execution inside a process, sharing the heap but with its own stack. Concurrency is many tasks making progress together, parallelism is many tasks truly running at the same time on several cores.

read, writeread, writeJVM processown memoryShared heapThread 1own stackThread 2own stackNeeds synchronization

3 points to say:

  1. Process: own memory, isolated, talks via IPC; thread: shared heap, own stack, cheap communication but needs synchronization.
  2. A platform thread maps 1:1 to an OS thread (~1 MB stack); a context switch between threads is cheaper than between processes but not free.
  3. Concurrency is structure (can interleave on one core); parallelism is simultaneous execution and needs several cores.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.