The idea is to wait on some condition - here called the guard.
But evaluating the guard must be done exclusively by only one thread!
Code using a condition variable - cond_var - would look like something like this:
pthread_mutex_lock(&mutex); while(!guard) { pthread_cond_wait(&cond_var, &mutex); } statement 1; ... statement n; pthread_mutex_unlock(&mutex);