Transferred from: https://www.cnblogs.com/caosiyang/archive/2012/10/15/2724585.html
There are times when it is necessary to do how many threads are currently running inside the process, so here are a few ways to use it.
1. Query According to the process number:
# pstree-p Process Number
# TOP-HP Process Number
2. Query according to the process name:
# pstree-p ' ps-e | grep Server | awk ' {print '} '
# pstree-p ' ps-e | grep Server | awk ' {print '} ' | Wc-l
This takes advantage of pipeline and command substitution,
I learned about command substitution today, which means that commands that are enclosed are prioritized and then output as arguments to other commands.
The above is with Ps-e | grep Server | The output (process number) of awk ' {print '} ' as a parameter to the PSTREE-P
The difference between pipeline and command substitution is:
Pipe: Pipe Symbol "|" Output from the left command as input to the right command
Command substitution: The output of the command in the command substitution "'" as a parameter for the corresponding location of the other command
View the number of threads in a process under Linux (GO)