DEV Community

Cover image for Program vs Process vs Thread
icncsx
icncsx

Posted on

Program vs Process vs Thread

Program

A program is simply an executable file that contains a set of instructions to complete a task. An application such as Chrome is one example.

Process

A process is any currently running instance of a program. So one program can have several executions (copies) of it running at once. One Chrome program can have multiple tabs/windows open. A colleague compares the relationship between a program and process to the difference between a Docker image and a container; I hope that analogy makes sense :)

Thread

One process can have multiple running threads. Put simply, a thread does lightweight, singular jobs. Threads exist for added concurrency. A process can have many jobs: think saving a file, reading keyboard input, writing logs, etc. Each thread can be responsible for its own task or "subprocess" so to speak.

Top comments (1)

Collapse
 
jimmont profile image
Jim Montgomery

This is very helpful to understand. A process is a running instance of a program, with isolated resources (memory, etc) and a collection of threads. Threads share the resources of the process, with each thread handling the scheduling and execution of respective tasks. The threads can update items in memory for other threads to do their respective thing.