blob: ffb6287711da77f3632a5d046f95854a6d9ff118 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <errno.h>
2#include <stdio.h>
3#include <string.h>
4#include <pthread.h>
5#include <time.h>
6
7static void *
8test_thread (void *v_param)
9{
10 return NULL;
11}
12
13int
14main (void)
15{
16 unsigned long count;
17 struct timespec ts;
18 ts.tv_sec = 0;
19 ts.tv_nsec = 10 * 1000;
20
21 setvbuf (stdout, NULL, _IONBF, 0);
22
23 for (count = 0; count < 2000; ++count)
24 {
25 pthread_t thread;
26 int status;
27
28 status = pthread_create (&thread, NULL, test_thread, NULL);
29 if (status != 0)
30 {
31 printf ("status = %d, count = %lu: %s\n", status, count,
32 strerror (errno));
33 return 1;
34 }
35 else
36 {
37 printf ("count = %lu\n", count);
38 }
39 /* pthread_detach (thread); */
40 pthread_join (thread, NULL);
41 nanosleep (&ts, NULL);
42 }
43 return 0;
44}