Timeline for supporting synchronized with virtual threads, was Re: JEP proposed to target JDK 19: 425: Virtual Threads (Preview)
Alan Bateman
Alan.Bateman at oracle.com
Sun Jun 5 19:44:14 UTC 2022
On 05/06/2022 10:13, Mark Rotteveel wrote:
> I have a question about the wording in JEP-425. Loom currently doesn't
> fully work with synchronized-blocks (underlying system thread will be
> pinned), and it currently says about that
>
> """
> In a future release, we may be able to remove the first limitation
> above (pinning inside synchronized).
> """
>
> This sounds rather vague/unspecific, and I wonder if this means "this
> is an unsolved problem and we don't know if we can ever solve this",
> or if this means "we'll fix it in the next preview" (or some other
> reasonably close release).
>
> The reason I'm asking is that I maintain a JDBC driver that currently
> relies heavily on synchronized combined with blocking I/O, and
> rewriting it to use ReentrantLock or something, requires some
> investment of time. If support for synchronized will be available
> "soon" (say, ~1 year), that is an investment that doesn't really pay
> off (for me), if it won't materialize for years (or ever), rewriting
> *is* a worthwhile investment.
It's a significant project and there isn't a time frame or status right now.
For the JDBC driver I wouldn't expect it to require a lot work as I will
guess this is locking that is internal to the JDBC driver and you aren't
exposing lock objects in any API. In that case, it should be mostly
mechanical to replace the monitors used around the blocking I/O with
j.u.concurrent locks.
-Alan
More information about the jdk-dev
mailing list