Dump all threads (stack traces) to stdout. From outside the process:
jstack <pid> > thread_dump.txt
Or send QUIT (3) to the JVM process:
kill -3 <pid>
Thread dump is printed to the process stdout (e.g. console or the file your runtime redirects to). For containers, ensure stdout is visible (e.g. not buffered) or use jstack from a sidecar/tool that can attach to the JVM.
If jstack is not on PATH, use the one from the same JDK as the running process: $JAVA_HOME/bin/jstack <pid>.