Computer ScienceProgrammingMedium

Thread (computing)

Also known as:execution threadlightweight processOS thread

A thread is the smallest unit of execution within a process, representing an independent sequence of instructions that can be scheduled by the operating system. Multiple threads within a single process share the same memory space (heap, global variables) but each maintains its own stack, program counter, and register state. Threads enable concurrency and parallelism within applications, and are central to modern programming in systems languages (C++, Java, Go) as well as high-level frameworks.

Process vs Thread Characteristics

PropertyProcessThreadNotes
Memory spaceSeparate (isolated)Shared within processThreads can share data directly
Creation overheadHigh (fork/exec)LowThreads are "lightweight processes"
CommunicationIPC (pipes, sockets)Shared memoryThreads communicate faster
Crash isolationStrongWeak (one crash kills all)Process isolation is safer
Context switch costHighLowerSame address space saves TLB flush

Interactive Tools

Codecademy – Java Threads

Open Tool

Brilliant – Operating Systems

Open Tool

Khan Academy – Processors and Threads

Open Tool
Diagram of a process containing multiple threads each with their own stack

Wikimedia Commons, CC BY-SA

Related Terms

The metaphor of a "thread of execution" derives from the textile concept of a single strand running through a fabric. The term was formalised in operating systems research in the 1960s–70s, popularised by the POSIX pthreads standard (1995).

threadconcurrencyoperating-systemsmultithreadingprocessscheduling