Skip to content

Instantly share code, notes, and snippets.

View kuriringohankamehameha's full-sized avatar

Vijay kuriringohankamehameha

View GitHub Profile
@rtv
rtv / cond.c
Created February 19, 2013 19:56
An example of using pthread's condition variables, showing how to block a main thread while waiting for worker threads to finish their work, without joining the threads. This could be useful if you want to loop the threads, for example.
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
/* Compile like this:
gcc --std=c99 -lpthread cond.c -o cond