lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #include <errno.h> |
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
| 4 | #include <pthread.h> |
| 5 | #include <time.h> |
| 6 | |
| 7 | static void * |
| 8 | test_thread (void *v_param) |
| 9 | { |
| 10 | return NULL; |
| 11 | } |
| 12 | |
| 13 | int |
| 14 | main (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 | } |