aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog5
-rw-r--r--linuxthreads/Examples/ex9.c14
2 files changed, 15 insertions, 4 deletions
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 <sjmunroe@vnet.ibm.com>
+
+ * Examples/ex9.c (main): Use list of children and join them.
+ (thread): Do not call exit.
+
2002-06-20 Ulrich Drepper <drepper@redhat.com>
* 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);