Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3903791
  • 博文数量: 534
  • 博客积分: 10470
  • 博客等级: 上将
  • 技术积分: 4800
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-26 14:08
文章分类

全部博文(534)

文章存档

2021年(1)

2019年(1)

2017年(1)

2016年(2)

2013年(2)

2012年(10)

2011年(43)

2010年(10)

2009年(17)

2008年(121)

2007年(253)

2006年(73)

分类: C/C++

2006-12-14 14:21:08

void pthread_exit(void *retval)
int pthread_join(pthread_t th, void **thread_return)

pthread_join()的调用者将挂起并等待th线程终止,retval是pthread_exit()调用者线程(线程ID为th)的返回值,
如果thread_return不为NULL,则*thread_return=retval。
需要注意的是一个线程仅允许唯一的一个线程使用 pthread_join()等待它的终止,并且被等待的线程应该处于可join状态,即非DETACHED状态

------------------------
for (i = 0; i < 10; i++)
{
  if (pthread_create((pthread_t *)&pthr[i].id, NULL,
            (void *)thr_function, (void *)pthr[i]))
  {
    fprintf(stderr, "Create pthread error: %s\n", strerror(errno));
    goto err_flg;
  }
}

for (i = 0; i < 10; i++)
{
  if (pthr[i].id != 0)
    pthread_join(pthr[i].id, NULL);
}
阅读(5267) | 评论(0) | 转发(0) |
0

上一篇:ORA-01480

下一篇:Oracle ROWNUM的实践

给主人留下些什么吧!~~