int n=0; pthread_mutex_t m; void* f(void* p){ phread_mutex_lock(&m); n++: pthread_mutex_unlock(&m); return NULL; }