What’s the difference between a thread and a process in software?

What’s the difference between a thread and a process in software?

TL;DR
A process defines a memory space
A thread is a unit of execution

The Process…

…defines the memory space your application will use. It’s not executable in it’s own right. In order for your application to run, the process is associated with a thread. In the case of a multithreaded design, the process is shared between every thread your application uses.

The Thread…

…is a unit of execution. It defines an executable path through your application and runs within the context of it’s process.

All threads within a process share the same memory space. In a multithreaded design this can cause issues unless you take precautions to write and implement thread safe code.

Why is this important to know?

 

This is a very common interview question, especially in the world of realtime, embedded software development. I myself have used it on many, many occasions as it helps build a picture about the depth of the candidate’s domain knowledge.

Share your thoughts...