Pinning and other pitfalls
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
know when virtual threads do not help.
Planned topics
- Pinning: a virtual thread cannot unmount while blocked, holding its carrier. Causes include blocking inside
synchronizedon older JDKs and native frames; newer JDKs reducesynchronizedpinning (verify version). - Diagnose with JFR's virtual thread pinned event or
-Djdk.tracePinnedThreads(verify flags). - CPU-bound work gains nothing; carriers equal about the number of cores.
- Downstream limits: 10,000 virtual threads can hit a 10-connection database pool, so the bottleneck moves.
- Use semaphores or pool limits to protect downstream resources.
Draft outline details
Demonstration
a table: workload / benefit — blocking HTTP: high; JDBC with small pool: bounded by pool; CPU loop: none.
Check your understanding
Why can a database pool still be the bottleneck?
Show answer
Many virtual threads compete for the same fixed number of connections.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.