Today we look at the behaviour of our five parallelMap implementations (Java streams, streams with a ForkJoinPool, raw threads, a threadpool with futures, and coroutines) when it comes to errors and cancellation. This is particularly important for us because we will be using the map with network calls which are subject to failure.
We also have a nicer microbenchmark implemetation using JUnit RepeatedTest to warm up HotSpot. Compared to JMH https://github.com/openjdk/jmh I think we can say, "never mind the rigour, feel the convenience"
There has been some discussion on Reddit about my use of AtomicReference in the threads implementation. I'm persuaded that any old non-thread-safe holder would do, and would probably be more performant - / j089h0d
You can see the whole of this series as a playlist
• All Gilded Rose Episodes
and the code on GitHub
https://github.com/dmcg/gilded-rose-tdd
If you like this, you’ll probably like the book Java to Kotlin, A Refactoring Guidebook
http://java-to-kotlin.dev
Also if you're going to KotlinConf in April 2023, you could work with Nat Pryce and me at our TDD workshop at KotlinConf https://kotlinconf.com/workshops/