Computers do many things at once. 
Computers do many things at once. 
A thread is a tiny part of a bigger task. A big task is called a process. Many threads can live in one process.
Threads share things like memory. This helps them work together fast. They can share the same code.
Threads are easy to make and use. They do not use as much room as big tasks. This keeps the computer running well.
Threads help computers do more work. They make everything feel smooth.
Computers run many tasks at once. One way they do this is with threads. 
A thread is a tiny set of steps. It is the smallest part of a program that a computer can manage. Threads usually live inside a larger unit called a process.
Think of a process like a large office. The office has its own space and tools. Threads are like workers inside that office. These workers share the same desks and files. This sharing makes it easy for them to talk. They also share the same code and memory.
Threads are much lighter than processes. Creating a new process takes a lot of work for the computer. It is like building a whole new office. Making a thread is much faster. It is more like giving a worker a new task.
Because they are fast, threads help computers work well. In the past, most computers had one core. Now, many computers have many cores. This means they can run many threads at the same time. This makes everything feel smooth and quick.
Computers perform many tasks at the same time to stay fast. One way they do this is through a thread of execution. A thread is the smallest sequence of programmed instructions that a scheduler can manage. 
Threads work by sharing what the process already owns. Multiple threads in one process share the same executable code. They also share the values of variables and memory. This sharing makes it very easy for threads to communicate. They can simply use the data and files they already have. However, this sharing also means they can cause trouble for each other. If one thread performs an illegal operation, it can crash the entire process. This would stop all the other threads in that application too.
People have been working with these ideas for a long time. In 1967, IBM used something called "tasks" in its OS/360 system. A person named Victor A. Vyssotsky is credited with using the term "thread" in 1966. Later, the Mach implementation of threads was described in the summer of 1986. Windows NT was the first version of Windows to use threads when it came out in 1993. In 1995, the IEEE created the pthreads API. This helped make multithreaded programming work across different Unix-like systems.
There are many different types of threads used in computing. Kernel threads are managed by the operating system itself. They are a lightweight unit of scheduling. User threads are managed in userspace, which means the kernel does not even know about them. Some user threads are even called "green threads" when used by virtual machines. There are also fibers, which are very light units of scheduling. Fibers use cooperative scheduling, so they must explicitly yield to let others run.
Understanding threads helps us see how modern hardware works. Most computers today use CPUs with multiple cores. In 2002, Intel added support for multithreading to the Pentium 4 processor. They called this "hyper-threading." By the year 2005, new dual-core processors arrived from Intel and AMD. On a single-core system, the computer uses "time slicing" to switch between threads quickly. This happens so fast that it feels like they run at the same time. On multi-core systems, different threads can truly run in parallel.
In computer science, a thread of execution is the smallest sequence of programmed instructions that a scheduler can manage independently. A scheduler is a part of the operating system that decides which tasks get to use the processor. Most threads exist as components within a larger unit called a process. While a process acts as a container for resources, a thread acts as the unit of execution itself. 
To understand how threads work, we must look at how they interact with a process. A process is a heavyweight unit that owns specific resources. These resources include memory for code and data, file handles, and sockets. When multiple threads exist within a single process, they share these resources. They specifically share the executable code and the values of dynamically allocated variables.
There are several distinct types of threads used in different computing environments. Kernel threads are managed directly by the operating system. They are lightweight units of scheduling that exist within a process. At least one kernel thread must exist in every process. User threads are managed in userspace, meaning the kernel is unaware of them. Some implementations, like those used by virtual machines, call these "green threads." There are also fibers, which are even lighter units of scheduling. Fibers use cooperative scheduling, meaning a running fiber must explicitly yield control to allow another fiber to run.
The history of threading shows how computing has evolved over decades. Threads first appeared as "tasks" in IBM's OS/360 batch processing system in 1967. The term "thread" itself is credited to Victor A. Vyssotsky in 1966. In the summer of 1986, the Mach implementation of threads was described. Windows NT became the first version of Windows to support threads when it was released in 1993. In 1995, the IEEE defined the pthreads API. This provided a standard interface for portable multithreaded programming across Unix-like systems. This standardization allowed developers to write code that worked on many different types of computers.
Threading is significant because of how it handles hardware resources. Creating and destroying processes is relatively expensive for a computer. This is because the system must acquire or release many resources. In contrast, thread switching is relatively cheap. It requires a context switch, which involves saving and restoring registers and the stack pointer. However, it does not change virtual memory, making it "cache-friendly." On single-core systems, the CPU uses time slicing to switch between threads. The CPU switches so frequently, often every 100 to 200 milliseconds, that users perceive the tasks as running in parallel.
Modern hardware has changed how we use threads through multi-core technology. Until the early 2000s, most desktop computers used only a single-core CPU. In 2002, Intel introduced simultaneous multithreading in the Pentium 4 processor, known as hyper-threading. By 2005, dual-core processors became more common, such as the Pentium D from Intel and the Athlon 64 X2 from AMD. On these multi-core systems, multiple threads can execute in true parallel. Each core can execute a separate thread at the exact same time. This allows software to achieve much higher performance levels by utilizing every part of the chip.
Finally, threading connects to broader concepts of scheduling and concurrency. Scheduling can happen at the kernel level or the user level. It can also be preemptive or cooperative. In preemptive scheduling, the operating system can interrupt a thread at any time to let another run. This gives the system fine-grained control over execution time. In cooperative multithreading, threads must voluntarily relinquish control. This can be efficient, but it can also cause problems if a thread refuses to yield. Understanding these different models helps programmers choose the best way to build fast and stable software.
🖼️ Images & Media (2)
More to explore
✨ What else?
Related topics you might enjoy
🔬 Go deeper
More advanced topics to explore
🪜 Step back
Simpler topics to build understanding
What is Nepedia?
A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.