Experience of adding JDK21 virtual thread support to a DB application
Ron Pressler
ron.pressler at oracle.com
Sat Jun 29 13:53:56 UTC 2024
> On 21 Jun 2024, at 16:57, Matthew Swift <matthew.swift at gmail.com> wrote:
>
> I know that ReentrantLock is supposed to be a little bit less efficient in highly contended situations, but I was surprised by an 8-10% impact. Is that expected?
I wouldn’t say at all that it’s supposed to be slightly less efficient but rather, as Alan mentioned, the behaviour of ReentrantLock and native monitors is a little different — monitors spin for a bit before blocking. The reason this isn’t the default for ReentrantLock is that this may or may not be what you want, depending on circumstance. However, the ReentrantLock API supports adding spinning manually with a loop calling ReentrantLock.tryLock in the condition and Thread.onSpinWait in the body.
— Ron
More information about the loom-dev
mailing list