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