If the condition is true, do_other_stuff will be called without locking the mutex, and then the mutex will be released without locking it. Bad mistake!
Just without goto
if( you_think_youre_genius ) { pthread_mutex_lock(&mutex); } else { ... pthread_mutex_lock(&mutex); //Assumming no expetion thrown do_stuff(); } do_other_stuff(); pthread_mutex_unlock(&mutex);
Manoj r
source share