Looking deeper into threads
Before delving into the technical details, let’s first understand what problems threads are designed to solve.
Modern computers and smartphones today are commonly equipped with multi-core CPUs. This architecture enables the computer to perform multiple tasks in parallel. This is a dramatic improvement compared to 15 years ago, when single-core CPUs were the norm, and dual-core CPUs were a luxury for tech enthusiasts.
However, even with older, single-core CPUs, you weren’t limited to performing just one task at a time. You could listen to music while browsing the web, for example. How is that possible? The CPU employs a task-switching strategy, much like your brain does when multitasking. When you’re reading a book and listening to someone talk at the same time, your attention is divided between the two activities, switching back and forth.
Although modern CPUs can handle multiple requests simultaneously, consider a scenario...