diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-06-30 04:04:20 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-06-30 04:04:20 +0000 |
commit | 95fdc6a0f61a389e92a6b84250c2286b4808b626 (patch) | |
tree | 54afe4d2de7ab4aeb9a6d0943ab90d8ddc794c0a /linuxthreads/Examples | |
parent | 8b8cc76fa47fe0819e5e52e29c6674e799df646e (diff) | |
download | glibc-95fdc6a0f61a389e92a6b84250c2286b4808b626.tar.gz glibc-95fdc6a0f61a389e92a6b84250c2286b4808b626.tar.xz glibc-95fdc6a0f61a389e92a6b84250c2286b4808b626.zip |
Update.
2002-06-19 Steven Munroe <sjmunroe@vnet.ibm.com> * Examples/ex9.c (main): Use list of children and join them. (thread): Do not call exit.
Diffstat (limited to 'linuxthreads/Examples')
-rw-r--r-- | linuxthreads/Examples/ex9.c | 14 |
1 files changed, 10 insertions, 4 deletions
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); |