-
-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Jaybird currently uses a lot of synchronized blocks for thread-safety. Java 19 introduces virtual threads with Project Loom (as a preview feature). Virtual threads and synchronized blocks currently don't work well together (or more correctly, seriously reduce the benefits/usability of virtual threads due to thread pinning). See https://openjdk.org/jeps/425 for details. Although JEP 425 says "In a future release, we may be able to remove the first limitation above (pinning inside synchronized).", this is not a solved problem, and may never surface (see https://mail.openjdk.org/pipermail/jdk-dev/2022-June/006721.html).
As a result, replacing synchronized blocks with reentrant locks (and maybe at the same time, look at reducing use of locks) makes sense to allow Jaybird to make use of virtual thread without pinning (that is, for the pure-java protocol, as calling native methods will still cause pinning).