0Pricing
Java Academy · Lesson

Pitfalls: Pinning and ThreadLocals

Avoid blocking carrier threads.

Things That Can Go Wrong

Virtual threads are powerful, but two pitfalls can quietly undermine their scalability: pinning and overuse of ThreadLocals.

This lesson explains both and how to avoid them.

What Is Pinning

Pinning happens when a virtual thread cannot unmount from its carrier while blocked. The carrier OS thread stays stuck, defeating the scalability benefit.

When too many carriers are pinned, throughput collapses.

All lessons in this course

  1. What Are Virtual Threads
  2. Creating Virtual Threads
  3. Platform vs Virtual Threads
  4. Pitfalls: Pinning and ThreadLocals
← Back to Java Academy