开发者

Synchronization statistics not available in the JVMTI API?

开发者 https://www.devze.com 2023-02-25 03:18 出处:网络
The class java.lang.ThreadInfo provides some very useful methods which provide statistic concerning synchronization in Java. For instance:

The class java.lang.ThreadInfo provides some very useful methods which provide statistic concerning synchronization in Java. For instance:

getBlockedTime() Returns the approximate accumulated elapsed time (in milliseconds) that the thread associated with this ThreadInfo has blocked to enter or reenter a monitor since thread contention monitori开发者_StackOverflow社区ng is enabled. [...]

getWaitedCount() Returns the total number of times that the thread associated with this ThreadInfo waited for notification. [...]

I cannot find functions to access these information from the JVMTI API. Do I overlook it or do I have to collect these information myself?


Besides from synchronization statistic, it seems you cannot even get a Threads id, which can be obtained by using Thread.currentThread().getId();


It's not quite as straightforward, but I think you can arrive at the blocked time and wait count via JVMTI events (see the events to do with "monitors": "Monitor Contended Enter" and "Monitor Wait" etc).

Re the thread IDs, no it doesn't look like JVMTI assigns these. On the other hand, I'm not sure that the IDs given in ThreadInfo actually refer to any "real" ID assigned by the O/S.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号