```cpp
#include <stdio.h>
#include <pthread.h>
#include <string.h>
void * callback(void * arg) {
printf("child thread id : %ld\n", pthread_self());
return NULL;
}
int main() {
pthread_t tid;
int ret = pthread_create(&tid, NULL, callback, NULL);
if(ret != 0) {
char * errstr = strerror(ret);
printf("error : %s\n", errstr);
}
for(int i = 0; i < 5; i++) {
printf("%d\n", i);
}
printf("tid : %ld, main thread id : %ld\n", tid ,pthread_self());
pthread_exit(NULL);
printf("main thread exit\n");
return 0;
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/f5aa0a7477b24643a4b2d1ffe3bb9185.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBAcXFfNDMxMDgyNTI=,size_20,color_FFFFFF,t_70,g_se,x_16)