#include #include #define NUM_THREADS 8 void *threadFunc(void *pArg) { sleep(1); int* p = (int*)pArg; int myNum = *p; printf("Thread number %d\n", myNum); } main() { int i; pthread_t tid[NUM_THREADS]; for (i = 0; i < NUM_THREADS; i++) pthread_create(&tid[i], NULL, threadFunc, &i); for (i = 0; i < NUM_THREADS; i++) pthread_join(tid[i], NULL); }