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 Unix, you can also generate a thread dump from any console using these commands:

Note that this doesn't actually kill the process.

The precise syntax and content of a thread dump is dependent on the Java Runtime.

The Java Mission Control, JConsole, and Visual VM tools also let you view thread information.

See Also :
Stack trace as String