a thread of execution
/ thread (rhymes with 'red') /
When a program runs, something has to keep track of where it is: which line of code it is executing, and the chain of function calls it is inside. A thread is exactly that - one independent flow of control marching through the instructions. The name is a good picture: it is a single thread you can follow through the code, the path the CPU takes as it executes one statement after another. A simple program has one thread, starting in main() and threading its way down through the calls.
Concretely, a thread is the smallest unit the operating system schedules onto a CPU. Each thread has its own program counter (a marker for the next instruction to run) and its own stack (the region of memory holding its function calls' local variables and return addresses). A program can ask the operating system to create additional threads, and then several threads run inside the same program, each with its own current position and its own stack, but otherwise sharing the program's memory. The operating system gives each thread turns on the CPU, switching between them so they all advance.
Why threads exist: they let one program do several things at once - keep a user interface responsive while a download runs, serve many clients at the same time, or split a big computation across CPU cores. That power comes with a cost we will spend this whole field on: because threads in the same program share memory, two threads touching the same data at the same time can corrupt it. A thread is cheap and powerful, but threads sharing state are the source of the hardest bugs in systems programming.
A text editor often runs at least two threads: one watches the keyboard and redraws the screen so typing feels instant, while another quietly auto-saves your file to disk. They run in the same program, sharing your document in memory, but follow two separate paths through the code.
Two threads, one program: separate positions and stacks, shared memory.
A thread is not a separate program and not a CPU core. It is a flow of control that the OS schedules; you can have far more threads than cores, and the OS time-slices them onto whatever cores exist.