Reader small image

You're reading from  Kotlin Design Patterns and Best Practices - Third Edition

Product typeBook
Published inApr 2024
PublisherPackt
ISBN-139781805127765
Edition3rd Edition
Right arrow
Author (1)
Alexey Soshin
Alexey Soshin
author image
Alexey Soshin

Alexey Soshin is a software architect with 18 years of experience in the industry. He started exploring Kotlin when Kotlin was still in beta, and since then has been a big enthusiast of the language. He's a conference speaker, published writer, and the author of a video course titled Pragmatic System Design
Read more about Alexey Soshin

Right arrow

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...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Kotlin Design Patterns and Best Practices - Third Edition
Published in: Apr 2024Publisher: PacktISBN-13: 9781805127765

Author (1)

author image
Alexey Soshin

Alexey Soshin is a software architect with 18 years of experience in the industry. He started exploring Kotlin when Kotlin was still in beta, and since then has been a big enthusiast of the language. He's a conference speaker, published writer, and the author of a video course titled Pragmatic System Design
Read more about Alexey Soshin