You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pinning does not make an application incorrect, but it might hinder its scalability. If a virtual thread performs a blocking operation such as I/O or BlockingQueue.take() while it is pinned, then its carrier and the underlying OS thread are blocked for the duration of the operation. Frequent pinning for long durations can harm the scalability of an application by capturing carriers.
The scheduler does not compensate for pinning by expanding its parallelism. Instead, avoid frequent and long-lived pinning by revising synchronized blocks or methods that run frequently and guard potentially long I/O operations to use java.util.concurrent.locks.ReentrantLock instead. There is no need to replace synchronized blocks and methods that are used infrequently (e.g., only performed at startup) or that guard in-memory operations. As always, strive to keep locking policies simple and clear.
Background
According to https://openjdk.org/jeps/425:
Other references (solutions & problems)
Discussion
I personally opt-in for the
ReentrantLock
usage pattern introduced by thepgjdbc
team:This is then used in
try-with-resource
blocks like this:This plays nicely with existing tools/checks that we have (https://errorprone.info/bugpattern/MustBeClosedChecker)
The text was updated successfully, but these errors were encountered: