10 Concurrent programs
In this chapter you will learn
- how to declaratively design concurrent program flows
- how to use lightweight virtual threads (fibers)
- how to safely store and access data from different threads
- how to process a stream of events asynchronously
—Claude Shannon
So far in the book we’ve been focusing on sequential programs: each program consisted of a sequence of expressions that were evaluated one by one using a single execution thread, usually connected to a single core.
We won’t be focusing on cores (or CPUs) in this chapter. We will focus on having multiple threads. Note that multiple threads can still run on a single core. The operating system switches between different threads to make sure everyone gets a chance to progress.
