Virtual Threads - deadlock with synchronized (Main.class) and System.out.println

Alan Bateman Alan.Bateman at oracle.com
Wed Jul 19 09:28:20 UTC 2023


On 19/07/2023 09:57, Davor Hrg wrote:
> that is interesting, I do not understand the details enough to it will 
> actually help :)
>
> can someone elaborate ?
>

You'll need to read the previous messages, it's essentially a 
starvation/deadlock issue where the chosen waiter to unpark cannot 
execute as all carriers are pinned by threads trying to enter a monitor 
that is owned by thread that is also waiting to acquire the lock. The 
right solution is to re-implement monitors, work in progress on that. 
There are some workarounds, including a system property to force the 
java.io code to use monitors. Heinz's clever workaround is also to force 
System.out to use monitors.

-Alan


More information about the loom-dev mailing list