thread
also: lightweight process, execution thread, POSIX thread, pthread
A lightweight execution unit within a process that shares the same memory space and resources as other threads in that process. Multiple threads can run concurrently, allowing parallel execution within a single program.
A thread is the smallest unit of execution within a process. Unlike processes, which are isolated with separate memory spaces, multiple threads within the same process share heap memory, file descriptors, and other resources. This makes threads more efficient for concurrent tasks that need to exchange data.
Each thread has its own stack, program counter, and CPU registers, allowing independent execution. For example, a web server might use one thread per client connection, all within a single process, rather than spawning separate processes.
Linux implements threads using the POSIX threading library (pthread) or kernel-level threads. You can view threads with commands like ps -eLf or top -H, where each thread appears as a separate line. Threads are essential for responsive applications that perform I/O operations or need to handle multiple tasks simultaneously.