1#include <stdio.h>
2#include <pthread.h>
3#include <unistd.h>
4
5int threads_up_and_running = 0;
6
7void *
8second_thread (void *in)
9{
10 pthread_setname_np ("second thread");
11 while (1)
12 sleep (seconds: 1);
13 return NULL;
14}
15
16void *
17third_thread (void *in)
18{
19 pthread_setname_np ("third thread");
20 while (1)
21 sleep (seconds: 1);
22 return NULL;
23}
24
25int 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

source code of lldb/test/API/macosx/thread-names/main.c