article banner

The third edition of Kotlin Coroutines: Deep Dive book is finally ready!

I am happy to announce that the third edition of the book Kotlin Coroutines: Deep Dive is finally ready and released!

What has changed since the first edition?

But before I tell you what is new, I just need to make one thing clear: both previous editions are not outdated. AFAIK they both stay up to date with the latest Kotlin Coroutines version. The second edition only added more content, including a whole new part.

The third edition is mainly a result of what I learned over the past two years. I not only worked with Kotlin Coroutines a lot, but I also conducted over 20 editions of Kotlin Coroutines workshop since the first edition of this book. With each workshop, I find new ways to explain certain concepts, I learn what is not clear for developers, and what is interesting for them. I also sometimes experiment with different workshop structures. As a result, I significantly changed the structure of the second part of the book.

Here is the list of the most important changes:

  • Over 40 exercises were added to the book. I am a big fan of learning by doing, so I hope you will find them useful. You can find their solutions at the end of the book.
  • I merged chapters Coroutine builders and Coroutine scope functions into one, named Starting coroutines. This chapter provides comprehensive picture of how to start coroutines, and complete explanation of structured concurrency. Because of this change, the explanation of withContext moved to the chapter Coroutine context, the explanation of withTimeout moved to the chapter Cancellation, and the explanation of supervisorScope moved to the chapter Exception handling.
  • The chapters Cancellation and Exception handling were significantly extended and clarified. They concentrate not on practical use-cases and common mistakes, and also present a clear explanation of how the mechanisms of cancellation and exception handling work.
  • I significantly changed chapters How does suspension work?, Job and children awaiting (renamed to Job and coroutine lifecycle).
  • I added more practical examples, use-cases, and the short chapter The bigger picture that primes the reader for understanding how to use coroutines in real-life projects.
  • Book margins and font size were changed to smaller. Otherwise, paperback would be too big, now it has 500 pages! The biggest reason for this change is exercises and solutions (solutions alone take over 50 pages).

3.1 Update

On 2022-07-23, I released the 3.1 update. It includes the following changes:

  • The chapter Why Kotlin Coroutines? has changed completely. It now presents the most important advantages of Kotlin Coroutines, including synchronization, cancellation, testing, and Flow (you can find updated chapter here).
  • The chapter about synchronization access to a shared mutable state was completely rewritten. Now it presents a complete and deep explanation of the most important synchronization tools, like atomic values, concurrent collections, synchronized blocks, dispatcher limited to a single thread and mutex (you can find updated chapter here).
  • Some exercises changed, particularly the first exercises after Starting coroutines and Testing coroutines sections.
  • The chapter Cancellation was extended with a short new section about CancellationException catching and rethrowing.
  • There were minor updates in sections dedicated to Flow.

Upgrade to the third edition

If you purchased this book on LeanPub or on Kt. Academy store, you can always download the most recent version of the book.

If you purchased the first or the second edition on Amazon, if you Tweet a photo of the book with @ktdotacademy, we will send you a coupon code for the second edition of the ebook on LeanPub.

Where can you find this book?

Kotlin Coroutines: Deep Dive ebook can be found in store or on LeanPub and paperback can be found on Amazon. You can also find an ebook on Amazon, but the price is higher than on LeanPub, due to Amazon rates.

More about the book on this page.