#include #include int val=0; void* sakana(void* x){ int c=1000000; while(c--){ //printf("%s\n", "sakana"); val++; //usleep(random()%1010); } } void* tako(void* x){ int c=1000000; while(c--){ //printf("%s\n", "tako"); val++; //usleep(random()%1000); } } main(){ pthread_t thre1, thre2; pthread_setconcurrency( 2 ); pthread_create(&thre1, NULL, sakana, NULL); pthread_create(&thre2, NULL, tako, NULL); pthread_join(thre1, NULL); pthread_join(thre2, NULL); printf("val %d\n", val); }