Butcher Virtual Threads like a pro!
summary
Demo shows creating 1 million virtual threads in ~8 seconds but only when threads just sleep; CPU-bound work on those threads still saturates cores and runs no faster than platform threads. Reproduces a real bug using Toxiproxy + Testcontainers and an Elasticsearch client, finds a synchronized call with the deprecated high‑level client pins virtual threads (detected via jdk.VirtualThreadPinned JFR event), fixes by switching to the modern client or removing synchronization. Warns against swarming tasks, ignoring interrupts, mutating scope values, and misusing virtual threads for CPU work.
AI-written summary · about
chapters (12)
- 0:00Introduction to virtual threads
- 3:42About the speaker
- 5:49Talk disclaimers and warnings
- 7:33Virtual threads limitations
- 10:24How virtual threads work
- 11:07What not to do with virtual threads
- 15:50Demo pinning virtual threads
- 27:59Quantum physics and virtual threads
- 33:24Parallel streams vs virtual threads
- 40:32Structured concurrency explained
- 45:33Scope values introduction
- 50:14How to misuse virtual threads
related talks
57mButcher Virtual Threads like a pro!
49mButcher Virtual Threads like a pro!
57mButcher Virtual Threads like a pro!
43mVirtual Threads: Taming the Wild Multithreading Beast
42mVirtual Threads - what we won or lose using it.
45mIntroduction and pitfalls of virtual threads
46mJava 21: The Revolution of Virtual Threads - A Deep Dive
01h 10mScaling Servers with Virtual Threads
