Commit | Line | Data |
---|---|---|
1 | #include <unistd.h> // pour sleep | |
2 | #include <pthread.h> // pthread_create, pthread_join, pthread_exit | |
3 | #include <stdio.h> | |
4 | ||
5 | static void* fonction(void* args) { | |
6 | printf("pid du thread fils = %d\n", getpid()); | |
7 | while (1); // forever | |
8 | return NULL; | |
9 | } | |
10 | ||
11 | int main() { | |
12 | pthread_t thread; | |
13 | ||
14 | printf("pid de main = %d\n", getpid()); | |
15 | pthread_create(&thread, NULL, &fonction, NULL); | |
16 | while (1); // forever | |
17 | return 0; | |
18 | } |