[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pthread resources



On Fri, 3 Mar 2000, Allan M. Wind wrote:
> main() {
> 	pthread_t p, p2;
> 	char *c;
> 	char c2[] = "something";
> 
> 	c = strdup("some data");
> 	pthread_create(&p, 0, f, c);
> 	pthread_create(&p2, 0, f2, c2);
> 
> 	exit(0);
> 	/*
> 	  what happens with p and p2 here - will they or c2 be out of
> 	  scope?  Do I need a join before the exit(0)
> 	*/
> }
> 
> 
> void *f(void *v) {
> 	free(v);
> 	// let the thread sleep for a while
> }
> 
> void *f2(void *v) {
> 	// let the thread sleep for a while
> }

PThreads Programming, published by ORA is a very good book for starting
out with pthreads I found. :)

When you explicitly call exit() it is supposed to terminate all threads in
the program. Not sure if it does under Linux though.

=--------------------------------------------------=
Mike Kelly	<kellym@nbnet.nb.ca>
		http://halcyon.nothinbut.net/~kellym

  'Two roads diverged in a wood, and I --
   I took the one less traveled by,
   And that has made all the difference.'

		-- Robert Frost
=--------------------------------------------------=



Reply to: