linux 查看某个进程的线程数

以查看mysql为例

获取mysql的pid

> netstat -anp|grep "mysql"
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      14108/mysqld

方法一:

> cat /proc/14108/status
Name:   mysqld
State:  S (sleeping)
Tgid:   14108
Pid:    14108
PPid:   13824
TracerPid:      0
Uid:    497     497     497     497
Gid:    501     501     501     501
Utrace: 0
FDSize: 256
Groups: 501 
VmPeak:  1146932 kB
VmSize:  1146928 kB
VmLck:         0 kB
VmHWM:     95632 kB
VmRSS:     95628 kB
VmData:  1106984 kB
VmStk:        88 kB
VmExe:      8788 kB
VmLib:      3652 kB
VmPTE:       356 kB
VmSwap:        0 kB
Threads:        18
......

方法二:

> ls /proc/14108/task/|wc -l
18

方法三:

> ps hH -p14108|wc -l
18