// /usr/bin/gcc -g -Wall -Wextra -Werror -std=c17 -o thread_test.bin thread_test.c -lpthread #include #include #include void *thread_function(void *_arg) { unsigned int *arg = (unsigned int *)_arg; printf(" new thread: my tid is %u\n", *arg); return NULL; } int main() { pthread_t thread; pthread_create(&thread, NULL, thread_function, &thread); // pass the thread id to the new thread printf("main thread: my tid is %lu\n", (unsigned long)pthread_self()); usleep(2000); return 0; }