LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 901|回复: 3

关于线程问题

[复制链接]
发表于 2006-9-28 18:27:36 | 显示全部楼层 |阅读模式
请教各位:

示例代码如下:

pthread_t thread_a,thread_b,thread_c;

void a()
{
    while(1)
      do_something;
}

void b()
{
    while(1)
      do_something;
}

void c()
{
    while(1)
      do_something;
}

void d()
{
     pthread_create(&thread_c,NULL,c,NULL);
     pthread_join(thread_c,NULL);
}

int main()
{
    pthread_create(&thread_a,NULL,a,NULL);
    d();
    pthread_create(&thread_b,NULL,b,NULL);
    return 1;
}

我现在想问的是,有什么办法可以让pthread_create(&thread_b,NULL,b,NULL);执行呢?
也就是说让函数b()执行呢?有什么办法呢?要调用写什么操作呢?
谢谢了
发表于 2006-9-28 18:30:55 | 显示全部楼层
狂汗。。。。。。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-9-28 19:28:42 | 显示全部楼层
刚才又做了实验,将pthread_join(thread_c,NULL);注释掉后,发现似乎好像可以。不知道各位还有没有其他方法?
回复 支持 反对

使用道具 举报

发表于 2006-9-29 09:04:43 | 显示全部楼层
你去查一下pthread_join()做什么的吧!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表