| 1 | #include <stdio.h> |
|---|---|
| 2 | #include <pthread.h> |
| 3 | #include <unistd.h> |
| 4 | |
| 5 | int threads_up_and_running = 0; |
| 6 | |
| 7 | void * |
| 8 | second_thread (void *in) |
| 9 | { |
| 10 | pthread_setname_np ("second thread"); |
| 11 | while (1) |
| 12 | sleep (seconds: 1); |
| 13 | return NULL; |
| 14 | } |
| 15 | |
| 16 | void * |
| 17 | third_thread (void *in) |
| 18 | { |
| 19 | pthread_setname_np ("third thread"); |
| 20 | while (1) |
| 21 | sleep (seconds: 1); |
| 22 | return NULL; |
| 23 | } |
| 24 | |
| 25 | int main () |
| 26 | { |
| 27 | pthread_setname_np ("main thread"); |
| 28 | pthread_t other_thread; |
| 29 | pthread_create (newthread: &other_thread, NULL, start_routine: second_thread, NULL); |
| 30 | pthread_create (newthread: &other_thread, NULL, start_routine: third_thread, NULL); |
| 31 | |
| 32 | threads_up_and_running = 1; |
| 33 | |
| 34 | while (1) |
| 35 | sleep (seconds: 1); |
| 36 | } |
| 37 |
