#include #include #include #include #include int done; pthread_cond_t c = PTHREAD_COND_INITIALIZER; pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; void *new_thread(void *arg) { printf("new thread\n"); pthread_mutex_lock(&m); done = 1; pthread_cond_signal(&c); pthread_mutex_unlock(&m); return NULL; } int main(int argc, char *argv[]) { pthread_t p; printf("main: begin\n"); pthread_create(&p, NULL, new_thread, NULL); pthread_mutex_lock(&m); while (!done) { pthread_cond_wait(&c, &m); } pthread_mutex_unlock(&m); printf("main: end\n"); return 0; }