In this blog post, the author discusses their experience with virtual threads in Java 21 and how they encountered deadlocks in a TPC-C for PostgreSQL implementation. They explain that virtual threads can be beneficial for handling concurrent tasks without the overhead of physical threads, but they also highlight the potential for deadlocks, particularly when using external libraries. The author provides a detailed example of a deadlock they encountered and explains how they fixed it by wrapping the connection with a semaphore. They conclude by stating that while virtual threads are a remarkable feature, they should be used carefully.
https://blog.ydb.tech/how-we-switched-to-java-21-virtual-threads-and-got-deadlock-in-tpc-c-for-postgresql-cca2fe08d70b