#include #include #include int sum = 0; void *compute(void *data) { int i; for (i = 0; i < 1000; i++) { sum++; } } int main() { int i, n; pthread_t *threads; scanf("%d", &n); threads = (pthread_t*) malloc(n * sizeof(pthread_t)); for (i = 0; i < n; i++) { pthread_create(&threads[i], NULL, compute, NULL); } for (i = 0; i < n; i++) { pthread_join(threads[i], NULL); } printf("%d\n", sum); free(threads); return 0; }