#!/bin/bash
set -o nounset
set -o errexit

# Usage: threaddumps.sh 1234
# where 1234 is the java process id
#
# note: jstack must be located in the PATH environment

if [ $# -eq 0 ]
then
	echo "Usage: threaddumps.cmd [pid]"

	exit
fi

for i in {1..30} ; do
	echo Thread dump $i
	jstack -l $1 > threaddump-$1-$(date +%H%M%S)-${i}.txt;
	sleep 2s;
done
