= 100000000/N_THREAD; pthread_t threads[N_THREAD]; int rets[N_THREAD]; for(i=0; i<N_THREAD; i++){ idx[i].begin = i*base; idx[i].end = (i+1)*base; rets[i] = pthread_create(&threads[i], NULL, (void *)calc_thread, (void *)&idx[i]); } void *statuses[N_THREAD]; for(i=0; i<N_THREAD; i++){ rets[i] = pthread_join(threads[i], &statuses[i]); } double sum = 0.0; for(i=0; i<N_THREAD; i++){ sum += *(double *)statuses[i]; } printf("%.16f\n", sum); return 0; }