Subj : Re: how to return from pthread To : comp.programming.threads From : ptjm Date : Wed Jul 06 2005 05:03 am In article <42cad89e$0$773$3a628fcd@reader20.nntp.hccnet.nl>, Huub wrote: % I have a program, containing multiple sourcefiles. From 1 sourcefile, I % call 4 others, of which only the 1st has a thread. Now it appears, that % after successfully running the thread, program won't return to do the % next. It just ends after the thread. The thread is started with 'rc = % pthread_create(...)', next instruction is 'pthread_exit(NULL)'. Can you give a clearer picture of what you're doing? Is it this: pthread_t tid; pthread_create(&tid, NULL, tf, NULL); pthread_exit(NULL); ntf(); ntf2(); ? What this does is start a thread to execute tf(), then return from the original thread. I expect what you want to do is wait for that background thread to finish like this: pthread_create(&tid, NULL, tf, NULL); pthread_join(tid, NULL); ntf(); ntf2(); If so, then why use pthread_create() at all? Why not tf(NULL); ntf(); ntf2(); ? -- Patrick TJ McPhee North York Canada ptjm@interlog.com .