By default, with Hotspot, a CTRL-Break thread dump will not list what threads are holding java.lang.concurrent
locks. And I understand that with these locks, Hotspot cannot have information about at which stack frame a lock was acquired. If you add the JVM option -XX:+PrintConcurrentLocks
, then a CTRL-Break stack dump will list (after a thread's stack trace) any concurrent locks held by that frame. For example:
"D-Java-5-Lock" prio=6 tid=0x00000000069a1800 nid=0x196c runnable [0x000000000770f000]
java.lang.Thread.State: RUNNABLE
at com.Tester.longDelay(Tester.java:41)
at com.Tester$D.run(Tester.java:88)
Locked ownable synchronizers:
- <0x00000007d6030898> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
Without this option, it isn't possible to figure out what thread is holding this lock in a post-mortem. Why is this option not the default? Is there some non-obvious performance or stability penalty? When I search to find discussion of this, nothing comes up.