Learn how to take advantage of Kotlin's concurrency primitives to build robust, lock-free, highly efficient, concurrent applications.
About This Book
Build highly efficient, robust, and concurrent applications in Kotlin
Work through practical examples that will help you write concurrent lock-free code
Improve the overall speed of execution in multiprocessor and multicore systems
Who This Book Is For
Kotlin and Android developers who are interested in learning how to program concurrently to enhance the performance of their applications
What You Will Learn
Understand Kotlin's approach to concurrency and how it is different than that of Java
Learn how to implement suspending and async coroutines and write lock-free concurrent code
Learn how to decide in which thread a coroutine is executed
Learn how to create potentially infinite data streams that are loaded lazily and concurrently
Understand the best practices for error handling
Learn how to use channels, threads, mutexes, and actors, to synchronize your coroutines effectively
Uncover how coroutines work under the hood
The primary requirements of modern day applications are scalability, speed and making the most use of hardware. Kotlin solves this problem by providing immense support for concurrency. Many concurrent primitives of Kotlin, such as channels and suspending functions, are expected to be lock-free and disjoint-access parallel. This allows for new approaches to concurrency and creates unique challenges for the design and implementation of concurrent code. This book addresses those challenges and shows you how to write lock-free concurrent code that takes advantage of Kotlin's concurrency support.
Beginning with an introduction to Kotlin's coroutines, you will learn how to write concurrent code. You'll learn the fundamental concepts of concurrency needed to be able to write your own concurrent software in Kotlin. You'll learn how to communicate between and synchronize your threads and coroutines, and perform asynchronous programming. To make things interesting, we'll dive into some event-driven and reactive programming. You'll learn how to handle errors and exceptions and leverage multi-core processing. Also, we'll talk about how coroutines work internally, to get a low-level understanding of Kotlin's concurrency .Throughout the book we'll cover the building of an entire application, applying all that we've learnt along the way.