From 95fdc6a0f61a389e92a6b84250c2286b4808b626 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 30 Jun 2002 04:04:20 +0000 Subject: Update. 2002-06-19 Steven Munroe * Examples/ex9.c (main): Use list of children and join them. (thread): Do not call exit. --- linuxthreads/ChangeLog | 5 +++++ linuxthreads/Examples/ex9.c | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'linuxthreads') diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index fa1c8b0f5d..9102cd044c 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,8 @@ +2002-06-19 Steven Munroe + + * Examples/ex9.c (main): Use list of children and join them. + (thread): Do not call exit. + 2002-06-20 Ulrich Drepper * spinlock.c (wait_node_alloc): We cannot use compare-and-exchange. diff --git a/linuxthreads/Examples/ex9.c b/linuxthreads/Examples/ex9.c index dafb4065de..9b8aca3b94 100644 --- a/linuxthreads/Examples/ex9.c +++ b/linuxthreads/Examples/ex9.c @@ -32,7 +32,8 @@ static pthread_barrier_t barrier; int main (void) { - pthread_t th; + pthread_t th; + pthread_t thread_list[NUM_THREADS]; int i; if (pthread_barrier_init (&barrier, NULL, NUM_THREADS + 1) != 0) @@ -40,12 +41,17 @@ main (void) for (i = 0; i < NUM_THREADS; i++) { - if (pthread_create (&th, NULL, thread, NULL) != 0) + if (pthread_create (&thread_list[i], NULL, thread, NULL) != 0) error (EXIT_FAILURE, 0, "cannot create thread"); } (void) thread (NULL); - /* notreached */ + + for (i = 0; i < NUM_THREADS; i++) + { + pthread_join(thread_list[i], NULL); + } + return 0; } @@ -87,7 +93,7 @@ thread (void *arg) printf ("%04d: last serial thread %lu terminating process\n", ++linecount, (unsigned long) self); funlockfile (stdout); - exit (0); + return; } pthread_exit(NULL); -- cgit 1.4.1