7 /* function prototypes */
8 void *threadfun(void *arg
);
9 void diep(const char *s
);
14 int cnt
[NUM_THREADS
], i
;
16 for (i
= 0; i
< NUM_THREADS
; i
++) {
18 printf("Creating thread: %d\n", i
);
20 if (pthread_create(&tid
, NULL
, threadfun
, (void *)&cnt
[i
]))
21 diep("pthread_create");
23 if (pthread_join(tid
, NULL
))
24 diep("pthread_join()");
30 void *threadfun(void *arg
)
32 printf("Hello! I am thread: %d\n", *(int *) arg
);
36 void diep(const char *s
)