一般有四种
参考链接:Linux下获取线程ID
#include <pthread.h>
#include <thread>
#include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <sys/syscall.h>
#define gettid() syscall(__NR_gettid)
#define NUM_THREADS 5
using namespace std;
// 线程的运行函数
mutex mtx;
void fun(){
std::unique_lock<std::mutex> lck(mtx);
cout<<"This in fun()"<<endl;
cout<<"process id: "<<getpid()<<endl;
cout<<