Multithreading runs multiple executions, called threads, inside one process or application. Threads share the process’s memory while maintaining separate stacks, registers, and program counters. section 2.2.4
Sharing memory makes threads lighter and faster to create than processes, but removes process-level isolation. One thread can overwrite another’s work, so communication and synchronization matter. section 2.2.4
A multithreaded design typically combines:
- A shared data structure that threads read or update. section 2.2.4
- Separate execution roles, such as accepting requests and receiving external events. section 2.2.5
- A pool whose size can grow or shrink with demand. section 2.2.5
Sports-score service
A stream-reader thread consumes match events and updates shared scores. Client-handler threads answer browser requests by reading those scores, allowing multiple users to receive results concurrently. section 2.2.5
Use the architecture figure to trace how a stream reader, shared sports scores, and client-handler threads cooperate in a web server. section 2.2.5










