简体   繁体   English

请求Java ThreadInfo的堆栈跟踪?

[英]Requesting a stack trace for a Java 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. 我有一个应用程序在java.lang.management.ThreadInfo对象上调用getStackTrace() ,但调用生成的StackTraceElement数组是零长度。

Inspecting the Javadoc shows this (emphasis mine): 检查Javadoc显示了这一点(强调我的):

public StackTraceElement[] getStackTrace()

Returns the stack trace of the thread associated with this ThreadInfo. 返回与此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? 如何为此线程信息请求堆栈跟踪?

How are you calling getThreadInfo() ? 你是如何调用getThreadInfo()的

Are you specifying a stack trace depth? 您是否指定了堆栈跟踪深度?

getThreadInfo(long id, int maxDepth) Returns a thread info for a thread of the specified id, with stack trace of a specified number of stack trace elements. getThreadInfo(long id,int maxDepth)返回指定id的线程的线程信息,堆栈跟踪指定数量的堆栈跟踪元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM