贝贝花花包包店,精品555皮具,钱夹,皮夹

字体:  

使用ACE task 框架时遇到的一个问题

corrupt 发表于: 2008-8-17 12:17 来源: ACE 开发者

我有两个 类,姑且叫 A 类 和 B 类吧

class A: public ACE_Task<..>


{


public:
         int open();


int svc(void);

}; 实现
A:pen ()
{
    active();
}
A::svc ()
{
   while(1)
   {
     //这个只是表明意思
      if( EXIT == getq())
      {
          return 0;
      }
   }
   //日志记录
   L_DEBUG("the   A thread svc is exit");
}
class B: public ACE_Task<..>


{


public:
         int open();


int svc(void);
         int send();         int recv();

};


实现:


B:pen()


{


    //这里开启两个线程,一个是send线程,专门发送网络数据;一个recv线程,收取网络数据


    active(,2);


}


B::svc()
{
    //开启两个线程
    if(thred[0] == ...)
    {
       send();
    }
    else
    {
       recv();
    }
}
B::int send()
{
    while(1)
    {
      .......
    }
    //记录日志,说明已经退出
    L_DEBUG("the thread send is exit");
}
B::int recv()
{
    while(1)
    {
//使用A类中某个变量将消息放入A的队列
        A::putq()
      .......
    }
    //记录日志,说明已经退出
    L_DEBUG("the thread recvis exit");
}


主函数:


int main()
{
    A a  , B b;
    a.open();
    b.open();
     .............


    a.wait();
    b.wait();
}
程序执行后,创造条件让网络异常,那么a 和 b 都会退出, 可是程序概率性的出现 阻塞,是阻塞在 a.wati()中;


但是从日志中 我却可以明显的看到
("the   A thread svc is exit");
("the thread send is exit");
("the thread recvis exit");
说明 A 类和B类 的线程都已经退出了。 为什么还会阻塞住 呢 ?

如果我将线程属性改为 非  THR_JOINABLE  就不会发生, 为什么?