Linux多线程编程学习代码记录(代码已上传gitee,还请各位兄弟点个Star哦!)
https://gitee.com/chenshao777/linux_thread.git
笔记:
获取进程id
getpid()
获取线程id
pthread_self()
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
pid_t pid; //定义进程id变量
pthread_t tid; //定义线程id变量
pid = getpid(); //获取进程id
tid = pthread_self(); //获取线程id
printf("进程id is %u, 线程id is %x\n",pid,tid);
}