writing the condition variable part of locking
writing the condition variable part of locking