Check out example codes for "how to mutex lock in c". It will help you in understanding the concepts better.

Code Example 1

pthread_mutex_t my_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&my_mutex);
/* locked code */
pthread_mutex_unlock(&my_mutex);

Learn ReactJs, React Native from akashmittal.com