get current thread count
grep -s '^Threads' /proc/[0-9]*/status | awk '{ sum += $2; } END { print sum; }'
get the system thread limit
cat /proc/sys/kernel/threads-max