Table of Contents

SHELL

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}"
}

MISC

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

MORE

@related: bash arpalhands sync UnLock

@TaG: SynC CooP BaSh

<iframe width="420" height="315" src="http://www.youtube-nocookie.com/embed/m3hsJV_HZUk" frameborder="0" allowfullscreen></iframe>