Some snippets for synchronization using pthreads