Threads
In short: The smallest executable instruction sequence within a process — modern CPU cores, thanks to “simultaneous multithreading” (e.g. Intel Hyper-Threading), can often process two threads per core at once.
In more detail: A process can have several threads, which share the same memory area but run independently of each other. This allows, for example, an app to respond to user input while loading data in the background at the same time.
In Depth
Process vs. thread
A process has its own, isolated memory area that no other process can directly view — the operating system enforces this separation, to prevent a faulty or malicious program from damaging another program’s memory. Threads within the same process, by contrast, share this entire memory area, but each has its own stack (for local variables and function calls) and its own instruction pointer (which instruction runs next). This makes switching between threads (a context switch) considerably cheaper than switching between entire processes — less state has to be saved and restored.
Race conditions and synchronisation
Shared memory access also carries risks, though: if two threads access the same data uncoordinated at the same time, inconsistent intermediate states can arise (“race conditions”) — for example, if both threads want to increment the same counter by one at the same time and an increment gets lost, because both start from the same outdated value. Such conflicts are typically prevented with locking mechanisms (locks/mutexes): a thread “locks” access to a shared resource, works on it, and only releases the lock afterwards — other threads have to wait in the meantime. Incorrectly used locks can, in turn, lead to deadlocks, where two threads block each other, because each is waiting for a resource the other currently holds.
Hardware threads: simultaneous multithreading
At the hardware level (“logical threads” per CPU core, to be distinguished from the operating system’s software threads), simultaneous multithreading (SMT, marketed by Intel as Hyper-Threading) lets a single physical core manage two instruction streams at once. The basic idea: modern CPU cores have considerably more internal execution logic units than a single instruction stream can typically keep busy at once — a CPU spends a lot of time waiting, for example while data is being fetched from memory. When one logical thread is currently waiting on such a memory access, the physical core can, in the meantime, let the second logical thread keep running and use the otherwise idle computing capacity.
Why SMT doesn’t act like a second core
This brings a noticeable but limited extra gain (typically 15-30% more throughput, not the full 100% of a second real physical core), since both logical threads continue to share the same physical execution logic, the same cache and the same execution units — so they can slow each other down when both need exactly the same internal resource at the same time. For this reason, an operating system shows 16 logical processors for an 8-core CPU with SMT, but the actual computing performance is considerably below that of 16 real physical cores.