implemented basic mutex and condition