(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / linuxthreads / Examples / ex12.c
blobe986fec97f9c4931ab1df4830140c92458e09b07
1 /* Variant of ex6, but this time we use pthread_exit (). */
2 #include <errno.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <pthread.h>
6 #include <unistd.h>
8 static void *
9 __attribute__ ((noreturn))
10 test_thread (void *v_param)
12 pthread_exit (NULL);
15 int
16 main (void)
18 unsigned long count;
20 setvbuf (stdout, NULL, _IONBF, 0);
22 for (count = 0; count < 2000; ++count)
24 pthread_t thread;
25 int status;
27 status = pthread_create (&thread, NULL, test_thread, NULL);
28 if (status != 0)
30 printf ("status = %d, count = %lu: %s\n", status, count,
31 strerror (errno));
32 return 1;
34 else
36 printf ("count = %lu\n", count);
38 /* pthread_detach (thread); */
39 if (pthread_join (thread, NULL) != 0)
41 printf ("join failed, count %lu\n", count);
42 return 2;
44 usleep (10);
46 return 0;