Why is this Hotspot JVM option not the default? -XX:+PrintConcurrentLocks

荒凉一梦 提交于 2019-12-04 04:15:21

Well, my guess is that it is unstable, or the JVM maintainers (Sun-now-Oracle) simply don't want to maintain it as a supported feature. You can tell this simply by the -XX: prefix:

Options that are specified with -XX are not stable and are not recommended for casual use. These options are subject to change without notice.

- from Java HotSpot VM Options

Also from that page, that option can be dynamically enabled or disabled via the JDK management interface, so you can enable it via an MXBean if you need.

Flags marked as manageable are dynamically writeable through the JDK management interface (com.sun.management.HotSpotDiagnosticMXBean API) and also through JConsole. In Monitoring and Managing Java SE 6 Platform Applications, Figure 3 shows an example. The manageable flags can also be set through jinfo -flag.

Finally, the jstack Stack Trace tool can perform the same functionality at any time without requiring it enabled all the time.

I asked Oracle (my employer has a support contact) and the answer is basically that the option is safe to use and that many purely-diagnostic features are disabled by default and this is one of those options. IMO, if a diagnostic feature is safe and stable and doesn't introduce a performance penalty, then it should be on by default. It appears that this is not the view at (then) Sun and (now) Oracle.

Because, only ReentrantLocks know which threads they are related. To get this information on Runtime realization of this method go over heap to find all locks and their threads.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!