java – 测量线程锁定监视器的时间

我对信号量有锁争用,我想测量锁保存的时间.

有没有一些免费的测量工具?

尝试过Visual VM,我看到了锁争用,但我对时代更感兴趣.

谢谢你的任何消化.

我喜欢这50个

"[ACTIVE] ExecuteThread: '226' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=3 tid=0x00000001099fa000 nid=0x41e waiting for monitor entry [0xfffffffe5a8f9000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:292)
    - waiting to lock <0xfffffffeb063ebb0> (a weblogic.utils.classloaders.GenericClassLoader)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
    at com.thoughtworks.xstream.core.util.CompositeClassLoader.loadClass(CompositeClassLoader.java:69)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at com.thoughtworks.xstream.XStream.dynamicallyRegisterConverter(XStream.java:723)
    at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:696)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:445)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:385)
    at com.thoughtworks.xstream.XStream.<init>(XStream.java:342)

解决方法:

您可以使用Sun Studio Performance Analyzer并启用锁定分析.这将显示锁定所花费的时间.

jProfiler还有Thread / Monitor统计选项卡,所以你可以尝试一下.

另一种方法是通过以给定间隔对线程转储进行采样并手动计算来获得估计.

另一种方法是打印安全点统计(XX:PrintSafePointStatistics),这也打印出“以毫秒为单位的线程花费的时间”,详见JVM SafePointStatistics – Can anyone help interpret it.

上一篇:mysql锁定select查询中的行以进行更新


下一篇:mysql – 如何在复制该表时锁定InnoDB表以防止更新?