Question about using virtual thread

Alan Bateman Alan.Bateman at oracle.com
Mon Jun 19 06:31:04 UTC 2023



On 18/06/2023 23:04, Attila Kelemen wrote:
> I wrote some tests for connection pools and JDBC drivers [1]. However, 
> currently I have added only a limited number of options (H2, Postgres 
> with loom-aware driver, Postgres with old driver) and DBCP2 for 
> connection pool with the addition of semaphore based "connection pool".

I don't know anything about DBCP2 but I'm curious to know if you really 
need to use a Semaphore with DataSource.getConnection. If it doing JDBC 
connection pooling then I would expect it would block, waiting for 
someone else to close a Connection and return it to the pool.



> :
>
> While doing this I have noticed one thing however: H2 is very loom 
> unfriendly, because it is full of `synchronized`. The worst part is 
> that at some places they even documented that you can externally 
> synchronize via a synchronized block, meaning that if they are to fix 
> everything, that will be - in theory - a breaking change for H2. That 
> said, I can't imagine somebody using the same `PreparedStatement` and 
> similar objects concurrently. I'm in the process of trying to create a 
> version of H2 from which I remove all the synchronized blocks, but it 
> takes quite a bit of time.
>
Thanks for the info on H2, will be interesting to see how your 
experiment goes.

-Alan


More information about the loom-dev mailing list