I am currently learning C from MIT\'s Open Courseware course called Practical Programming in C. In discussing race conditions in multithreading, the lecture notes contained
You didn't initialize the mutex. You can either do this:
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
or in the main function, do this:
main
if ( pthread_mutex_init( &mutex, NULL) != 0 ) printf( "mutex init failed\n" );