线程值pthread_self函数使用

来源:互联网 发布:基坑设计知乎 编辑:程序博客网 时间:2024/06/08 06:51


#include<stdio.h>  
#include<pthread.h>  
#include<Windows.h> 
#include<signal.h>


#include<process.h>//getpid函数的使用


#pragma comment(lib, "pthreadVC2.lib")  //必须加上这句  




void*thread_func(void*arg)
{
printf("thread id=%lu\n",pthread_self());
return arg;
}


int main(void){
pid_t pid;
pthread_t tid;
pid = getpid();
printf("process id=%lu\n", pid);
    pthread_create(&tid, NULL, thread_func, NULL);
    pthread_join(tid,NULL);


return 0;

}



0 0
原创粉丝点击