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

Alan Bateman Alan.Bateman at oracle.com
Tue Jul 18 08:46:43 UTC 2023


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



More information about the loom-dev mailing list