1 2 3 4 5 6 7 8 9 10 11 12
| for (int i = 0; i < THREAD_NUM; ++i) { if (pthread_create(&tid[i], NULL, counter, (void *)&i) != 0) { perror("pthread_create error"); exit(1); } } for (int i = 0; i < THREAD_NUM; ++i) { if (pthread_join(tid[i], NULL) != 0) { perror("pthread_join error"); exit(1); } }
|