2020-09-04 10:27:13 +02:00

35 lines
652 B
C

//
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
int GlobV = 0;
void* action (void* increment) {
for (i=1 ; i<= NOMBRE; i++) globV = globV + *increment;
return 0;
}
int main (int argc; char* argv[]) {
pthread_t unThread;
int valeur;
assert (argc == 2);
valeur = atoi(argv[1];
if (pthread_create(&unThread, NULL, action, &valeur) {
perror("pthread_create");
exit(-1);
}
}
printf("\nmain : globV = %d \n\n", globV) ;
return (0);
}