0

Does getting a stack trace of a Java thread calling Thread.getStackTrace() have any impact on its performace?

EDIT: for monitoring purposes I would like to get stack traces of some monitored threads. I understand that parsing the stack of a thread could be a time consuming operation. In my case the most critical is that the performance of the thread for which the stack trace is being constructed is not affected.

digger
  • 233
  • 1
  • 8

1 Answers1

2

Yes, there will be performance impact when you try to getStackTrace(). It need to back track stack dump of this thread. Here is interesting SO discussion on this topic.

Community
  • 1
  • 1
kosa
  • 65,990
  • 13
  • 130
  • 167