if you are using shared data, use mutexes for both reading and writing. Surround your read and write sections with pthread_mutex_lock() and pthread_mutex_unlock(), or use them any time a program's invariant is temporarily broken.
Your Commento.io account has been suspended. Go to the Commento dashboard to resolve this.
Threads in C
pthreads library and threaded programming in C