Difference: Program VS Process VS Thread
Here are the definitions and the explanations from Wikipedia.
A computer program, or just a program, is a sequence of instructions, written to perform a specified task with a computer.
A process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.
A computer program is a passive collection of instructions; a process is the actual execution of those instructions. Several processes may be associated with the same program; for example, opening up several instances of the same program often means more than one process is being executed.
A thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system. The implementation of threads and processes differs between operating systems, but in most cases a thread is a component of a process. Multiple threads can exist within the same process and share resources such as memory, while different processes do not share these resources. In particular, the threads of a process share its instructions (executable code) and its context (the values of its variables at any given moment).
As you can see, you can consider a program is just a sequence of instruction stored in the secondary memory. It is not necessary to be loaded to RAM and not necessary to be executed.
However, for a process, it is a piece of program that is loaded, being executing and running in the system. Every instructions would probably be executed and the values of the declared variables would be charged accordingly.
In the pass, 1 process can only execute 1 task at the same time. But, thread gives a process the ability of executing various tasks at the same time, so that it may get the input data and calculate the result meanwhile. Thus, you may find several threads in the same process. Each thread has its own stack. In a process, or a program, there is only 1 thread by default but one may normally create multiple threads by “pthread” library, #include
You may check out more here: