Butcher Virtual Threads like a pro!
summary
Demo creates 1 million virtual threads sleeping to show low-memory cost but switches to CPU-bound work to prove virtual threads don’t speed CPU-heavy tasks. Reproduces a bug with toxyproxy + Testcontainers (~500ms delay) and JFR/JFRUnit to detect threads pinned by synchronized blocks (blocking IO inside synchronized causes carrier threads to stay mounted). Shows parallel streams vs virtual threads yield similar throughput for CPU work, demonstrates structured concurrency for immediate cancellation, and warns that mutable scope values reintroduce thread-local bugs.
AI-written summary · about
chapters (14)
- 0:00Introduction to virtual threads
- 4:54Meet the speaker
- 6:18History of Java concurrency
- 10:57How virtual threads work
- 14:33Misconceptions about virtual threads
- 16:18Common mistakes with virtual threads
- 27:44Virtual threads and CPU-bound tasks
- 33:18Observing virtual threads changes behavior
- 39:48Back pressure and virtual threads
- 40:31Structured concurrency explained
- 46:31Scope values in Java
- 50:01Demo of scope values
- 54:11How to misuse virtual threads
- 55:20Q&A and feedback request
related talks
52mButcher Virtual Threads like a pro!
49mButcher Virtual Threads like a pro!
43mVirtual Threads: Taming the Wild Multithreading Beast
45mIntroduction and pitfalls of virtual threads
50mVirtual Threads, Structured Concurrency, Extent Locals: When to Use Them & How
42mVirtual Threads - what we won or lose using it.
46mJava 21: The Revolution of Virtual Threads - A Deep Dive
01h 10mScaling Servers with Virtual Threads
