implementing condition variables1