Multithreading
Multithreading is a programming technique in which a single process runs multiple threads of execution concurrently, allowing different parts of a program to make progress independently while sharing the same memory space.
37 resources across 3 libraries
Glossary Terms(10)
Groovy
Groovy is a dynamic, optionally typed programming language that runs on the Java Virtual Machine, designed to interoperate seamlessly with Java while offering…
Multithreading
Multithreading is a programming technique in which a single process runs multiple threads of execution concurrently, allowing different parts of a program to m…
Concurrency
Concurrency is the ability of a program to make progress on multiple tasks during overlapping time periods, whether by truly running them simultaneously or by…
Parallelism
Parallelism is the simultaneous execution of multiple computations at the exact same instant, typically achieved by distributing work across multiple CPU cores…
Asynchronous Programming
Asynchronous programming is a programming model that allows a program to start a long-running operation, such as a network request, and continue executing othe…
Memory Leak
A memory leak is a defect in which a program allocates memory during execution but fails to release it after it is no longer needed, causing available memory t…
Web Worker
A Web Worker is a browser API that runs JavaScript code on a background thread, separate from the main UI thread, so CPU-intensive tasks don't block page rende…
Kernel
The kernel is the core component of an Operating System that has direct control over hardware resources — CPU, memory, and devices — and mediates access to the…
Process Scheduling
Process scheduling is the operating system mechanism that decides which of the many runnable processes or threads gets access to the CPU at any given moment, a…
Cache Coherence
Cache coherence is the property of a multiprocessor system in which all processor cores see a consistent, up-to-date view of shared memory data, even though ea…
Study Notes(4)
Multithreading in MFC
How MFC wraps Win32 threading into CWinThread, worker vs. UI threads, and the synchronization classes (CCriticalSection, CMutex, CEvent, CSemaphore) used to co…
Multithreading in Java
Learn how Java creates and runs multiple threads concurrently using the Thread class and Runnable interface, and why start() and run() behave so differently.
Multithreading in Python
How to run concurrent tasks with Python's threading module, and why the GIL limits CPU-bound parallelism.
Threads and Multithreading
Learn how threads differ from processes, why multithreading helps, and user-level vs kernel-level threads.
Interview Questions(23)
Difference Between Process and Thread
A process is an independent program in execution with its own private memory space, while a thread is a lighter unit of execution that lives inside a process a…
What is a Deadlock?
A deadlock is a situation where a set of processes are permanently blocked because each holds a resource the others need and is waiting for a resource another…
What is a Semaphore?
A semaphore is a synchronization primitive — an integer counter with atomic wait (P/down) and signal (V/up) operations — used to control access to shared resou…
Difference Between Mutex and Semaphore
A mutex is a locking primitive owned by exactly the thread that acquires it and enforces mutual exclusion over a single resource, while a semaphore is a counte…
What is a Race Condition?
A race condition occurs when two or more threads or processes access shared data concurrently and the final outcome depends on the unpredictable timing of thei…
What is the Producer-Consumer Problem?
The producer-consumer problem is a classic synchronization challenge where one or more producer threads generate data into a shared, fixed-size buffer while on…
What is a Condition Variable?
A condition variable is a synchronization primitive that lets a thread block until another thread signals that some shared condition has become true, always us…
What is Barrier Synchronization?
Barrier synchronization is a coordination mechanism where every thread in a group must reach a defined checkpoint before any of them is allowed to proceed past…
What is the Compare-and-Swap (CAS) Instruction?
Compare-and-swap (CAS) is an atomic CPU instruction that reads a memory location, compares it to an expected value, and only writes a new value if the comparis…
How is a Mutex Lock Actually Implemented?
A mutex is implemented as a memory word holding a locked/unlocked flag plus a wait queue, where acquiring it uses an atomic instruction such as compare-and-swa…
What is Busy Waiting and Why is it Costly?
Busy waiting is when a thread repeatedly checks a condition in a tight loop instead of yielding the CPU or being put to sleep, which wastes CPU cycles and star…
What Are Atomic Operations in an Operating System?
An atomic operation is one that executes as a single, indivisible step from the perspective of every other thread or CPU core, so no concurrent operation can e…
Overview of Synchronization Primitives: Mutex, Semaphore, Condition Variable, Spinlock
Synchronization primitives are the building blocks — mutexes, semaphores, condition variables, and spinlocks — that operating systems and languages provide to…
What is a Thread Pool and Why Use One?
A thread pool is a fixed or bounded group of pre-created worker threads that pull tasks from a shared queue, so an application avoids the cost of spawning and…
User-Level Threads vs Kernel-Level Threads
User-level threads are managed entirely by a runtime library in user space without the kernel knowing they exist, while kernel-level threads are created, sched…
How Does Thread Scheduling Work?
Thread scheduling is the mechanism by which the OS (or a user-space runtime) decides which of the runnable threads gets CPU time next, typically driven by prio…
What is Gang Scheduling?
Gang scheduling is a multiprocessor scheduling technique that schedules all the related threads of a parallel program to run simultaneously on separate CPU cor…
How Do Threads and Processes Differ in Memory Sharing?
Threads within the same process share the same address space — code, heap, and global data — and each only gets its own private stack and register set, whereas…
How Are Kernel Threads Implemented and Scheduled?
A kernel thread is a thread the operating system kernel itself creates, schedules, and manages directly, with its own kernel-level thread control block, so the…
What is a Light-Weight Process (LWP)?
A light-weight process (LWP) is a kernel-schedulable entity that acts as a bridge between a user-level thread library and the kernel, letting many user threads…
How is a Mutex Implemented Internally?
A mutex is implemented as a small in-memory state word — typically a lock bit plus a waiter count or queue — manipulated through an atomic hardware instruction…
How is a Semaphore Implemented Internally?
A semaphore is implemented as an integer counter protected by an atomic update, paired with a kernel-managed wait queue: the wait (P) operation atomically decr…
Binary Semaphore vs Counting Semaphore
A binary semaphore holds only two states, 0 and 1, and is used to guard a single resource much like a mutex, while a counting semaphore holds an integer that c…