LOCK="/var/lock/${0##*/}.lck"
function sys_create_lock
{
(ps -p $(readlink "${LOCK}")) &>/dev/null
[ "$?" != "0" ] && rm -f "${LOCK}"
ln -s $$ "${LOCK}" 2>/dev/null
res="$?"
[ "${res}" != "0" ] && exit "${res}"
trap sys_remove_lock EXIT
}
function sys_remove_lock
{
[ "$(readlink "${LOCK}")" == "$$" ] && rm -f "${LOCK}"
}
http://download.oracle.com/javase/tutorial/essential/concurrency/locksync.html
tutos : http://download.oracle.com/javase/tutorial/index.html
in french doc sur synchronized: : http://www.lifl.fr/~bogaert/clfc/polyDurif/node83.html
in french doc sur wait: http://www.lifl.fr/~bogaert/clfc/polyDurif/node84.html
http://download.oracle.com/javase/tutorial/essential/concurrency/guardmeth.html