10 Concurrent Programs
In this chapter you will learn how to
- declaratively design concurrent program flows
- use lightweight virtual threads (fibers)
- safely store and access data from different threads
- process stream of events asynchronously
We know the past but cannot control it.
We control the future but cannot know it.
— Claud Shannon
10.1 Threads... threads everywhere
So far in the book we’ve been focusing on sequential programs: each program consisted of a sequence of expressions which was 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. Operating system switches between different threads to make sure everyone gets a chance to progress. |
|