Question about using virtual thread

Attila Kelemen attila.kelemen85 at gmail.com
Tue Jun 27 23:17:05 UTC 2023


>
>
>
> I have a question regarding H2. Not all pinning due to synchronized is
> harmful; in fact, most uses of synchronized are benign and need not (and
> perhaps should not) be replaced with ReentrantLock. It is when pinning is
> *both* frequent and long-running that it adversely affects virtual threads’
> scalability. Obviously, if you make the DB sleep inside a synchronized
> block that would qualify as a problem, but since H2 is an in-memory
> database, did you also detect a problem with H2 and more realistic uses?
>
>
To be honest, you are right, I'm a bit exaggerating the issue given how H2
is often used. Though it is possible to show the pinning issue (just easier
to make it obvious with a sleep). The simplest way to do it is to require
H2 to lock tables. For example, by running concurrent INSERTs, etc. on the
same table. In that case, H2 with all the synchronized will be magnitudes
slower (than my no synchronized modification). Also, there is a server mode
for H2 (not that I tested it, or ever heard anyone using it ...).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230628/21c6350e/attachment-0001.htm>


More information about the loom-dev mailing list