Butcher Virtual Threads like a pro!
summary
Creates and destroys 1 million virtual threads to show they’re cheap but proves CPU-bound work doesn’t get faster, only scale improves; builds a containerized demo with Testcontainers + Toxiproxy + Elasticsearch that injects 500ms latency to catch pinning; detects pinned virtual threads with -Djdk.TracePinnedThreads and JFR and shows causes: long blocking IO, synchronized blocks, native calls; demonstrates the newVirtualThreadPerTask executor, scope values (immutable replacement for ThreadLocal), structured concurrency cancellation, and pitfalls like mutable AtomicInteger and improper monitoring.
AI-written summary · about
chapters (13)
- 0:00Virtual threads demo
- 1:48Flaws in naive demos
- 4:49Speaker introduction
- 6:35History of concurrency
- 9:20How virtual threads work
- 13:46Avoiding pinning
- 16:01Elasticsearch container demo
- 25:13Stream performance issues
- 30:41Monitoring risks
- 33:45Structured concurrency intro
- 35:58Scope values demo
- 41:18Structured concurrency demo
- 46:46Conclusion and Q&A
related talks
52mButcher Virtual Threads like a pro!
57mButcher Virtual Threads like a pro!
57mButcher Virtual Threads like a pro!
45mIntroduction and pitfalls of virtual threads
43mVirtual Threads: Taming the Wild Multithreading Beast
50mGet The Most Out of Virtual Threads in Java 25 -A Deep Dive into the Latest Achievements of Virtual
46mJava 21: The Revolution of Virtual Threads - A Deep Dive
47mSailing Modern Java
