Skip to content
Ameen Abozaid
Planned lessonMID-007-L04

Pinning and other pitfalls

  • Lesson 4 of 6
  • Mid-level
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 synchronized on older JDKs and native frames; newer JDKs reduce synchronized pinning (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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.