Dump thread information
There's a way of asking a Java Runtime to output a "thread dump" for all currently running threads (both system threads and application threads). For each thread, the thread dump will include a stack trace, and information on any locks currently held by the thread. Thread dumps don't cause your application to halt. They're like a snapshot: your application pauses execution, the running threads are queried, the information is output, and then your application simply resumes execution.
To cause a thread dump from the console that launched the application:
- on Windows, press Control + Break
- on Unix, press Control + Backslash
- find the application's process id, using ps x | grep java
- kill -3 <java-process-id>
Note that this doesn't actually kill the process.
The precise syntax and content of a thread dump is dependent on the Java Runtime.
See Also :
Would you use this technique?