请求 Java ThreadInfo 的堆栈跟踪?
我有一个应用程序在 java.lang.management.ThreadInfo
对象上调用 getStackTrace()
,但调用生成的 StackTraceElement
数组是零长度。
public StackTraceElement[] getStackTrace()
返回与此 ThreadInfo 关联的线程的堆栈跟踪。 如果没有为此线程信息请求堆栈跟踪,则此方法将返回零长度数组。如果返回的数组的长度非零,则数组的第一个元素表示堆栈的顶部,这是序列中最近的方法调用。数组的最后一个元素表示堆栈的底部,它是序列中最近的方法调用。
如何请求此线程信息的堆栈跟踪?
I have an application that calls getStackTrace()
on a java.lang.management.ThreadInfo
object, but the StackTraceElement
array produced by the invocation is zero length.
Inspecting the Javadoc shows this (emphasis mine):
public StackTraceElement[] getStackTrace()
Returns the stack trace of the thread associated with this ThreadInfo. If no stack trace was requested for this thread info, this method will return a zero-length array. If the returned array is of non-zero length then the first element of the array represents the top of the stack, which is the most recent method invocation in the sequence. The last element of the array represents the bottom of the stack, which is the least recent method invocation in the sequence.
How do I request a stack trace for this thread info?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您如何调用 getThreadInfo()?
您是否指定堆栈跟踪深度?
How are you calling getThreadInfo()?
Are you specifying a stack trace depth?