I would like to monitor the number of threads used by a specific process on Linux. Is there an easy way to get this information without impacting the performance of the proc
If you are trying to find out the number of threads using cpu for a given pid I would use:
top -bc -H -n2 -p | awk '{if ($9 != "0.0" && $1 ~ /^[0-9]+$/) print $1 }' | sort -u | wc -l