Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!reader01.nrc01.news.zen.net.uk.POSTED!not-for-mail Newsgroups: comp.programming.threads From: Geoff Clare Subject: Re: String multithreading issue References: <0992cd7c-02bf-47e6-8c88-a171b7de8408@googlegroups.com> <505c048c$0$6575$9b4e6d93@newsspool3.arcor-online.net> User-Agent: XPN/1.2.6 (Street Spirit ; Linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Fri, 21 Sep 2012 13:42:05 +0100 Message-ID: Lines: 21 Organization: Zen Internet NNTP-Posting-Host: 18336f1d.news.zen.co.uk X-Trace: DXC=ilZ9__>Sl]LgN9e0JNPkjOa0UP_O8AJoL=dR0\ckLKG@WeZ<[7LZNRFP5>N9ZB9 On 20.09.2012 17:53, bartek szurgot wrote: >> you do not join your threads, so you have a race - if threads will not >> end before program exits, you have a problem. > > Does pthreads kill the process, if the main thread ends? > Or is this just undefined behavior? Returning from the initial call to main() is equivalent to calling exit(). (The process is not killed; it terminates normally. Well, "normally" as far as its parent can tell. I don't mean to imply that exiting while other threads are running is a normal thing to do.) You can call pthread_exit() instead of returning from main(), and then the process will continue running until all of the other threads have terminated. -- Geoff Clare