My problem comes from real practice: I have an application, that depends on external (network) services. If some service become inaccessible my application freeze and I don't understand where problems come from.
I don't write application myself and source code doesn't used logging if something go wrong.
I run jconsole and see all threads with traces (like do this with procexp in my previous job for Windows native application). But there are 120 threads!!
So I want to find threads there some classes (or regex pattern for package/class) in trace and print that traces. So I find place where network wait take place.
jconsole application shown that this theoretically possible to do (but I really don't want clicks to all of 120 threads in jconsole interface I search by eyes there my packages).
Do I need to run a full debugger jdb? Do I need to start my app (which actually Spring application in Jboss application server) with some option to allow retrieving such info?
I am old live Emacs user, so dumping all thread with traces of locally running application by command line utility also resolve my problem.
I prefer connection to normally (without any debug tuning) running application as this seems unnecessary.
I run jvisualvm visit "Threads" tab and press "Thread dump" button and get asked info!!
So I can save report to file and perform searching in Emacs with regex.
I just forget that jconsole deprecated as only recently back to Java world (from low level C world).
But fill free point me to non-interactive command line solution...
UPDATE kill -QUIT $pid
make Java process to dump thread traces to stdout. jps -l
help to find Java process. If stdin redefined (Tomcat AS, etc) - check out AS logs!