0% completed
Program: A program is a set of instructions stored on your computer. It is a static entity that remains inactive until it is executed. For instance, consider a program designed to search through billions of entries in a database. This program resides passively on the hard drive until initiated.
Process: When you run or execute a program, it becomes a process. This is the active phase of the program, using memory and other system resources. If a program is an inactive entity stored on a hard drive, a process is its active state when it's executed and begins its operations.
Thread: Threads are parts of a process. A single process might split its task into multiple threads to work faster or more efficiently. While all threads in a process share the same resources, each thread works on its own individual task. For instance, in the task of searching through billions of database entries, a thread can concurrently sift through various portions of the database. One thread could tackle the initial 250 million records, while another handles the following 250 million, and so on
Aspect | Program/Application | Process/Executing Entity | Thread /Concurrent Entity |
---|---|---|---|
Description | A collection of instructions to accomplish a task. | A single running instance of a program. | A path of execution within a process. |
Autonomy | A component within larger systems. | It has its own address space and runs independently. | Executes in parallel with other threads within the same process. |
Resource Management | Doesn't actively manage them | Manages its own memory and resources. | Shares the memory space of its parent process |
Example | Think of an executable created to sift through billions of database entries that reside on a hard disk. This remains inactive until executed. | When executing the database scanning program, it becomes an active process, utilizing system memory and resources. | Within the process of scanning the database, individual threads can be assigned to search specific segments, such as one thread focusing on the first 250 million records, another on the next 250 million, and so on. |
In this lesson, we explored the fundamental concepts of threads, focusing on how they enable concurrent execution within a program. Now, let's dig deeper into the thread life cycle, which provides a deeper understanding of how threads transition through various states and interact with one another.
Table of Contents