请求Java ThreadInfo的堆栈跟踪? [英] Requesting a stack trace for a Java ThreadInfo?

查看:165
本文介绍了请求Java ThreadInfo的堆栈跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序在 java.lang.management.ThreadInfo 对象上调用 getStackTrace(),但是调用产生的 StackTraceElement 数组为零长度。

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.

检查 Javadoc 显示了这一点(强调我的):

Inspecting the Javadoc shows this (emphasis mine):

public StackTraceElement[] getStackTrace()




返回与此ThreadInfo关联的线程的堆栈跟踪。 如果没有为此线程信息请求堆栈跟踪,则此方法将返回零长度数组 。如果返回的数组长度为非零,则数组的第一个元素表示堆栈的顶部,这是序列中最近的方法调用。数组的最后一个元素表示堆栈的底部,这是序列中最近的方法调用。

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.

如何为此线程信息请求堆栈跟踪?

推荐答案

您如何调用 getThreadInfo()

您是否指定了堆栈跟踪深度?

Are you specifying a stack trace depth?


getThreadInfo(long id, int maxDepth)
返回指定id的线程的线程信息,堆栈
跟踪指定数量的堆栈
跟踪元素。

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.

这篇关于请求Java ThreadInfo的堆栈跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆