Hello, I'm trying to understand why the final resultt is alsways 20000 ?
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
int cpt;
void* f (void* unused){
if (cpt != 20000){
cpt++;
f(NULL);
}
}
int main(){
pthread_t tab_processus[10];
for (int i=0;i<10;i++){
pthread_create(&tab_processus[i], NULL, f, NULL);
}
for (int i=0;i<5;i++){
pthread_join(tab_processus[i], NULL);
}
printf("%d", cpt);
return 0;
}