Java Reference
In-Depth Information
14.12.2. Stack Traces
Any thread that is alive, can be queried for its current execution stack
trace. The getStackTrace method returns an array of StackTraceElement
objectsas described in " Stack Traces " on page 294 where the zeroth ele-
ment represents the currently executing method of the thread. If the
thread is not alive then a zero-length array is returned.
You can access the stack traces of all threads in the system using the
static THRead class method getAllStackTraces , which returns a map from
each thread to its corresponding StackTraceElement array.
Stack trace information is generally used for debugging and monitoring
purposesfor example, if your application "hangs," a monitoring thread
might display all the stack traces, showing you what each thread is do-
ing. Of course, if your application hangs because of an error in your
code, any such monitoring thread may itself not get a chance to ex-
ecute. The virtual machine is not required to produce non-zero-length
stack traces for any given thread, and it is also allowed to omit some
methods from the stack trace information.
 
Search WWH ::




Custom Search