liveBook · Manning

Multithreading

As explained in Learn Concurrent Programming with Go

Multithreading is a programming approach in which multiple threads execute concurrently within a single process or application.

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

Figure 2.7 A web server application serving sports scores

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

How Learn Concurrent Programming with Go covers it

How deep it goes
Explains thread structure, resource costs, shared memory, and risks, but does not detail synchronization mechanisms.
Examples
Illustrates a sports-score service with a stream-reader thread, client-handler threads, shared scores, and a dynamic thread pool.
What it assumes
Assumes a basic process model, then distinguishes threads from processes through execution, memory, and resource allocation.
What you can do after
Evaluate when lightweight shared-memory execution suits concurrent server work and recognize its isolation and coordination costs.
How it connects
Connects threads with processes, shared memory, synchronization, thread pools, and web servers.

Also explained in

Compare how 11 books explain multithreading →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Concurrent Programming with Go. The section links point to the parts of the book it draws on.