Flying Futures in the same sky can make the moon sun at midnight
summary
Title describes flaky tests caused by flying futures that share resources: concurrent Futures on the JVM race on mutable state so the moon can look like the sun at midnight. Concrete issues: visibility, lost updates, expensive OS threads. Practical fixes shown: thread pools / custom ExecutionContext, volatile, synchronized or AtomicReference, countdown latches; tradeoffs on performance. Functional alternatives demonstrated: ZIO fibers with fork and collectAll and STM retries until commit to provide atomic shared state, eliminating the race and making the example deterministically correct.
AI-written summary · about
chapters (11)
- 0:00Flying futures introduction
- 1:49Parallelism vs concurrency
- 3:34Shared mutable state issues
- 13:31Race conditions in programs
- 15:23Memory visibility problems
- 19:06Visibility and sync solutions
- 21:28ZIO introduction
- 25:24STM for atomic transactions
- 28:19Solving solar system with STM
- 30:56Why use concurrency libraries
- 31:45Closing and resources
related talks
53mFunctional Async on the JVM
51mFuture: Friendly Parallel Processing in R for Everyone
01h 53mAsynchronous and Concurrent Programming in Scala Part 2
58mBlazing Fast, Pure Effects without Monads
52mComparing Approaches to Structured Concurrency
01h 12mAsynchronous and Concurrent Programming in Scala Part 3
52mJoint Keynote Address
58mMonads in Chains
