When a user perceives a program to be freezing, but the rest of the computer is still working fine, it means that some important execution thread has a problem. Most of the times, simply looking at the stacktrace a programmer can often figure out what went wrong. Stack dumps enable us to get the stacktraces of all the threads of a running program in real time.
Performing a Stack Dump
In the java JDK there is a tool, that does just that, called jstack
(.exe under windows) in the jdk/bin directory.
First we need to obtain the process id of our java process (every OS assigns an unique integer to every running process), under windows this can be done using the task manager, on linux with the simple command sudo ps -a
.

once you have the id you simply run jstack(.exe) -l Process_ID >> path/or/dumpfile/only.dump
and open the dump using our text editor of choice.
Naming practices
Naming your threads really helps with identifying them. Do so like this:
Thread t = new Thread(somerunnable);
t.setName("meaningful name");
...
t.Start()