Coroutines and Loom behind the scenes
summary
OpenJDK Project Loom (preview since Java 19/20, targeted for Java 21) introduces virtual thread per request that lets a server swap a physical thread for a virtual one with a one-line change (newVirtualThreadPerTaskExecutor) and run 100k sleepy threads instantly — it works and memory drops from GBs to a few KB per fiber. Kotlin Coroutines remain lighter for fine‑grained concurrency (≈600 bytes vs ~2.6KB suspended cost) and Loom has hard limits: native calls and cannot unmount in synchronized sections.
AI-written summary · about
chapters (23)
- 0:00Coroutines and Project Loom intro
- 1:06Loom goals and features
- 3:13Demo: physical vs virtual threads
- 5:20Virtual threads for servers
- 6:47Legacy code thread issues
- 9:58Adopt virtual threads easily
- 11:01Debugging virtual threads
- 12:52Virtual threads save resources
- 15:21Loom limitations
- 17:10Kotlin coroutines intro
- 18:37Loom vs coroutines goals
- 20:43Loom vs coroutines style
- 22:06Event handling and concurrency
- 24:13Kotlin structured concurrency
- 26:02Why structured concurrency matters
- 28:07Loom vs coroutines implementation
- 31:18Memory usage: threads vs coroutines
- 34:48CPU performance challenges
- 35:51IO performance and libraries
- 37:37Tooling for threads and coroutines
- 39:47Best of Loom and coroutines
- 42:12Trade-offs with both
- 44:23Summary
related talks
45mCoroutines and Loom behind the scenes
50mAsync Showdown: Java Virtual Threads vs. Kotlin Coroutines
44mAsync Showdown: Java Virtual Threads vs. Kotlin Coroutines
49mWhat's New in Java 19: The end of Kotlin?
51mServer-side Kotlin with Coroutines
43mCoroutines for Java Developers
33mVisualising concurrency with Kotlin
01h 03mUsing Kotlin Coroutines for Asynchronous and Concurrent Programming
