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

Davor Hrg hrgdavor at gmail.com
Wed Jul 19 08:57:31 UTC 2023


that is interesting, I do not understand the details enough to it will
actually help :)

can someone elaborate ?

On Tue, Jul 18, 2023 at 10:48 PM Dr Heinz M. Kabutz <
heinz at javaspecialists.eu> wrote:

> On 2023/07/18 10:46, Alan Bateman wrote:
> > On 18/07/2023 07:29, Dr Heinz M. Kabutz wrote:
> >> Hi Ron,
> >>
> >> should this also be emitted with the -Djdk.tracePinnedThreads=full
> >> event? It doesn't seem to be at the moment.
> >
> > There's a lot of puzzler material here. That system property prints a
> > stack trace to System.out so it might, or might not, block trying to
> > acquire the lock for System.out. Before you ask, the reason you might
> > not see a JFR event is because that event is committed after the
> > pinned thread continues (so it can include the duration). In the
> > deadlock scenario, the thread that is pinned due to synchronized
> > (Main.class) { ... } is not chosen as the waiter to release, so it
> > parks indefinitely.
> >
> > -Alan
>
> Oh my, that is so nasty!
>
> Thus we can make the problem vanish with System.setOut(new
> PrintStream(System.out) {});
>
> :-)
>
> Heinz
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230719/c8f451f5/attachment-0001.htm>


More information about the loom-dev mailing list