change condition to pthread_cond