linux C 获取线程号
21 Mar 2014#include <iostream>
#include <sys/types.h>
#include <pthread.h>
#include <sys/syscall.h>
using namespace std;
pid_t gettid() {
return syscall(SYS_gettid);
}
int main() {
pid_t t;
t = gettid();
cout << "pid_t = " << t << endl;
return 0;
}