|
楼主 |
发表于 2006-7-25 17:12:51
|
显示全部楼层
static int stopthread(void)
{
// pthread_exit(NULL);
pthread_cancel(stopid);
}
static int awhile(void)
{
signal(47,stopthread);
while(1);
}
int main(void)
{
pthread_t eventid,stopid;
pthread_create(&eventid,NULL,(void*)genevent,NULL);
pthread_create(&stopid,NULL,(void*)awhile,NULL);
printf("the thread id in stopid= %ld\n",stopid);
if(!pthread_join(stopid,NULL))
{
printf("the thread exit successfully!\n");
}
}
其中genevent()函数会产生一个事件,然后发送一个信号47,我希望awhile()函数捕获到该信号之后,能够将stopid线程终止,请帮我看看有什么问题啊,在此谢了 |
|