Butcher Virtual Threads like a pro!
summary
Claim: virtual threads let the JVM host one million virtual threads only when those threads mostly sleep or wait; CPU‑bound work still saturates cores so throughput stays limited. Demo builds a reproducible failure using Testcontainers + NGINX + toxy proxy (latency injected) and JFR to show virtual threads get pinned when IO runs inside synchronized blocks. Code experiments show virtual threads don’t speed CPU work, parallel streams behave similarly, and fixes are: add backpressure, avoid pinning, make tasks interruptible, use structured concurrency and immutable scope values.
AI-written summary · about
chapters (15)
- 0:00Introduction to virtual threads
- 4:54About the speaker
- 6:18History of Java concurrency
- 9:11What are virtual threads
- 12:48How to use virtual threads
- 14:33Virtual threads limitations
- 16:18Mistakes to avoid with virtual threads
- 21:00Demo: Detecting pinned virtual threads
- 27:44Demo: Virtual threads and CPU-bound tasks
- 33:18Demo: Backpressure with virtual threads
- 40:31Structured concurrency explained
- 46:31Scope values in Java
- 48:15Demo: Scope values with Star Trek
- 54:11How to misuse virtual threads
- 55:20Call to action and closing
related talks
52mButcher Virtual Threads like a pro!
49mButcher Virtual Threads like a pro!
43mVirtual Threads: Taming the Wild Multithreading Beast
42mVirtual Threads - what we won or lose using it.
46mJava 21: The Revolution of Virtual Threads - A Deep Dive
45mIntroduction and pitfalls of virtual threads
01h 10mScaling Servers with Virtual Threads
50mVirtual Threads, Structured Concurrency, Extent Locals: When to Use Them & How
