33 lines
No EOL
583 B
C
33 lines
No EOL
583 B
C
#include <stdio.h>
|
|
#include <pthread.h>
|
|
#include <unistd.h>
|
|
|
|
|
|
void * fn_thread (void * p_int) {
|
|
for (int i = 0; i < *(int *) p_int; ++i) {
|
|
printf("et mon courroux\n");
|
|
sleep(1);
|
|
}
|
|
pthread_exit(0);
|
|
}
|
|
|
|
int main () {
|
|
int M = 0;
|
|
int N = 0;
|
|
pthread_t p1;
|
|
|
|
printf("Saisir M puis N : \n");
|
|
scanf ("%d", &M);
|
|
scanf ("%d", &N);
|
|
printf("Ok ! \n");
|
|
|
|
pthread_create (& p1, NULL, fn_thread, (void *) &N);
|
|
for (int i = 0; i < M; ++i) {
|
|
printf("Coucou\n");
|
|
sleep(1);
|
|
}
|
|
|
|
pthread_join(p1, NULL);
|
|
|
|
return 0;
|
|
} |