1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <pthread.h> #include <unistd.h> static int x; static void * thread_main(void *data) { sleep(1); return data; } int main(void) { pthread_t thread; if (pthread_create(&thread, NULL, thread_main, &x)) return 2; sleep(2); return 1; }