#include #include #include #include #include _Atomic int done; /* state variable */ void *new_thread(void *arg) { sleep(1); printf("new thread\n"); done++; return NULL; } int main(int argc, char *argv[]) { pthread_t p; printf("main: begin\n"); pthread_create(&p, NULL, new_thread, NULL); while(!done) ; printf("main: end\n"); return 0; }