
- 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
withContextmoved to the chapter Coroutine context, the explanation ofwithTimeoutmoved to the chapter Cancellation, and the explanation ofsupervisorScopemoved 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).
- 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
CancellationExceptioncatching and rethrowing. - There were minor updates in sections dedicated to Flow.
