Condition wait issue is most likely being caused by improper use of pthread_cond_wait. Hopefully this fixes it.