#include #include #include /* ================================== Thread prints "Hello World" ================================== */ void *worker(void *arg) { char dummy[10]; printf("Worker thread: hit enter to exit....."); scanf("%s", dummy); return(NULL); /* Thread exits (dies) */ } /* ================================================= MAIN: create a trhead and wait for it to finish ================================================= */ int main(int argc, char *argv[]) { pthread_t tid; /* --------------------- Create threads --------------------- */ if ( pthread_create(&tid, NULL, worker, NULL) ) { printf("Cannot create thread\n"); exit(1); } printf("Main thread is waiting for worker thread to finish...."); pthread_join(tid, NULL); printf("\npthread_join(tid, NULL) is done !!!\n\n"); printf("Done !\n"); }