Search⌘ K
AI Features

Program vs Process vs Thread

Explore the fundamental distinctions between a program, a process, and a thread in this lesson. Understand how processes execute programs and how multiple threads share resources within a process. Gain insight into common concurrency issues like thread interference when accessing shared data, laying a foundation for handling synchronization in Java multithreading.

Program

A program is a set of instructions and associated data that resides on the disk and is loaded by the operating system to perform some task. An executable file or a python script file are examples of programs. In order to run a program, the operating system’s kernel is first asked to create a new process, which is an environment in which a program executes.

Process

A process is a program in execution. A process is an execution environment that consists of instructions, user-data, and system-data segments, as well as lots of other resources such as CPU, memory, address-space, disk and network I/O acquired at runtime. A program can have several copies of it running at the same time but a process necessarily belongs to only one program.

Thread

Thread is the smallest unit ...