1. First find the Java process
top
ps to | grep java
2. Find the thread according to the pid
top -Hp pid
ps -mp pid -o THREAD,tid,time
3. Get the hexadecimal value of the thread id
printf "%x\n" tid
4. Output the stack information of the thread and execute jstack in the bin directory of jdk
./jstack pid | grep tid hex >> ./a.txt --- output data into a.txt file