6 static void * thread_doit(void *unused) {
7 int len = (int) ((drand48() * 5) + 1);
12 int main(int argc, char* argv[]) {
14 printf("Expected usage: %s THREAD_NUM\n", argv[0]);
18 int thread_num = atoi(argv[1]);
20 pthread_t *threads = malloc(sizeof(pthread_t) * thread_num);
22 for(int i = 0; i < thread_num; i++) {
23 pthread_create(&threads[i], NULL, &thread_doit, NULL);
26 for(int i = 0; i < thread_num; i++) {
27 pthread_join(threads[i], NULL);