I am not strong in OS and low level concepts in programming. So, any insight here would be awesome!
First of all, let's assume you have an operating system installed. Let's say, it's a Windows. On said Windows, you have an application. A file. It's called program.exe. This file is a program, because it executes commands which define the computer's behavior (or at least part of it). When you start the program by double-clicking on it, Windows will start a new process.
Operating systems use processes to separate programs. It's a means to run many programs, separate them and still keep overview over them. One process will execute one atomic command in one unit of time. There can be many processes running simultaneously on one computer. The operating system will make sure that you can run as many programs in their individual processes as you want by distributing computation time amongst them. One way to distribute the time is by using Round Robin Scheduling.
So what happens, if one program, running in one process, wants to execute an assynchronous action? It wants to read from a database, but reading from a database takes 10s. During these 10s, the GUI should stay responsive. It should not freeze and users should still be able to click stuff. Since one process can only work on one command at a time, programmers where in a bind. So intelligent people came up with the idea, that it should be possible to execute commands simultaneously. Like two processes (two programs) running next to each other, but more tightly coupled in one process. So they came up with multithreading.
One thread means one program which will execute one command after each other. Two threads is like two programs, each executing commands after each other, but separated and independent of each other. Especially with multi-core CPUs and techniques, like "Hyperthreading" it is possible to run different commands on different cores separately at the same time. So you can have many threads running in a process, of which the behavior is defined by a program.
A [PROGRAM] is executed in a [PROCESS] which might spawn multiple [THREADs] to do some work.
rahul kumar
Denny Trebbin
Lead Fullstack Developer. Experimenting with bleeding-edge tech. Irregularly DJ. Hobby drone pilot. Amateur photographer.
A process is an executing program - visible in the Activity Monitor / Process Explorer or Task Manager. One or more threads run in the context of the process. The operating system allocates processor time and memory per thread. An application or program consists at least one process and is mainly responsible for initializing the process(es).
Here you can see the hierarchy of Google Chrome on macOS
Here you can see that across all processes, Google Chrome spawned just 44 Threads (frequently changing as I use Google Chrome and cause threads to die or to spawn).