#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#define NUM_THREAD 8
void *th_main(void *arg){
unsigned i, sum = 0;
for(i = 0; i < 1000; i++) sum += rand();
printf("Thread#%d: sum = %u\n", pthread_self(), sum);
}
int main(){
int i;
pthread_t th[NUM_THREAD];
srand(time(NULL));
for(i = 0; i < NUM_THREAD; i++) pthread_create(&th[i], NULL, th_main, NULL);
for(i = 0; i < NUM_THREAD; i++) pthread_join(th[i], NULL);
return 0;
}

rand()ってスレッドごとに独立した系列の乱数列返すの?
既出だったらすいません。
環境はcygwin+gccです。