#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <pthread.h>
/**
* https://man7.org/linux/man-pages/man3/pthread_create.3.html
* https://www.geeksforgeeks.org/pthread_self-c-example/
*/
void* calls(void *ptr) {
printf("123\n");
sleep(1);
return ptr;
}
int main() {
pthread_t thread;
pthread_create(&thread, NULL, calls, NULL);
pthread_join(thread, NULL);
printf("456\n");
return EXIT_SUCCESS;
}
主线程调用pthread_join等待子线程执行完毕.