Java Virtual Threads: The Pinning Problem and the Fix in Java 24

Posted by Normal-Tangelo-7120@reddit | programming | View on Reddit | 31 comments

I came across an internal engineering writeup at my org where a production service stalled after adopting virtual threads, a feature introduced in Java 21 that lets you run millions of lightweight threads on a handful of OS threads. Switching back to platform threads fixed it immediately.

Turns out Netflix hit the exact same problem of virtual threads getting pinned inside synchronized blocks, exhausting all carrier threads, and hanging the application.

I put together a write-up with a demo one can run locally to see it happen. It goes into what pinning is and why it exists, how to read thread dumps to spot it