23,121
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <pthread.h>
#include <cstdio>
using namespace std;
void* pFunc(void*)
{
while(1)
{
cout<<"1"<<endl;
}
return NULL;
}
int main()
{
pthread_t pdID;
void *ret=NULL;
if(pthread_create(&pdID,NULL,pFunc,NULL)!=0)
{
perror("create");
return 1;
}
if(pthread_cancel(pdID)!=0)
{
perror("cancel");
return 3;
}
if(pthread_join(pdID,&ret)!=0)
{
perror("create");
return 2;
}
cerr<<"pthread ret"<<endl;
return 0;
}