topCount=15
pid=`pgrep java`
echo "pid:$pid topCount:$topCount cpu:$cpu"
>top
>stack
top -b -n 1 -Hp $pid | grep java | awk '{ printf("%x\t%s\t%d\n", $1, $11, $1) }' | sort -rnk2 >ttop_list
i=1
while [ $i -le $topCount ]
do
top -H -c -n 1 -b -p $pid | grep java | awk '{ if($9>1) {printf("%x\t%s\t%d\n", $1, $9, $1) }}' >>top
jstack -l $pid >>stack
sleep 0.1
eval i=$(($i+1))
done
#top -H -c -n $topCount -b -p $pid | grep java | awk '{ if($9>2) {printf("%x\t%s\t%d\n", $1, $9, $1) }}' >top
cat top | awk '{ cpu[$1] += $2; count[$1] +=1 } END { for(i in cpu) print i, cpu[i], count[i]}' | sort -k2rn >top_list