June 2018
Intermediate to advanced
310 pages
6h 32m
English
There are many books written about thread safety and there are good reasons for that. Concurrency bugs that are caused by lack of thread safety are the ones hardest to track. They're hard to reproduce, because you'll usually need a lot of threads competing on the same resource for an actual race to happen. Because this book is about Kotlin and not thread safety in general, we'll only scratch the surface of this topic. If you're interested in the topic of thread safety in the JVM language, you should check out the book Java Concurrency in Practice by Brian Goetz.
We'll start with the following example, which creates 100,000 threads to increment a counter:
var counter = 0val latch = CountDownLatch(100_000)for (i in 1..100_000 ...
Read now
Unlock full access