aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads/Examples/ex9.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-06-30 04:04:20 +0000
committerUlrich Drepper <drepper@redhat.com>2002-06-30 04:04:20 +0000
commit95fdc6a0f61a389e92a6b84250c2286b4808b626 (patch)
tree54afe4d2de7ab4aeb9a6d0943ab90d8ddc794c0a /linuxthreads/Examples/ex9.c
parent8b8cc76fa47fe0819e5e52e29c6674e799df646e (diff)
downloadglibc-95fdc6a0f61a389e92a6b84250c2286b4808b626.tar
glibc-95fdc6a0f61a389e92a6b84250c2286b4808b626.tar.gz
glibc-95fdc6a0f61a389e92a6b84250c2286b4808b626.tar.bz2
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/ex9.c')
-rw-r--r--linuxthreads/Examples/ex9.c14
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);