Threads and Coroutines
In this chapter, we'll discuss how our application can efficiently serve thousands of requests per second. In the previous chapter, we already had one glimpse at it—reactive streams use a number of different threads (exposed by the Schedulers API), and we even had to create a thread once or twice with the thread() function. But before we dive into nuances, let's first discuss what kind of problems threads are able to solve.
In your laptop, you have a CPU with multiple cores, probably four of them. That means that it can do four different computations in parallel, which is pretty amazing, considering that 10 years ago, a single-core CPU was the default and even two cores were only for enthusiasts.
But even back then, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access