三线程同步的问题!我认为是巨难的!我的三个线程关系如下:Function A()
{
return x;
}Function B()
{
创建运行 Function A(); 并需要立即返回,不能等待!
}Function C()
{
创建运行 Function B(); 等待 Function A() 执行完毕后 以Function A()的返回值做为依据进行下一步操作!}

解决方案 »

  1.   

    HANDLE m_hFunAEventKill;
    Function a()
    {
        m_hFunAEventKill= CreateEvent(NULL, TRUE, FALSE, NULL);
        //do your work
        SetEvent(m_hFunAEventKill);
        return x;
    }
    Function C()
    {
    创建运行 Function B(); 
    WaitForSingleObject(m_hFunAEventKill);//等待 Function A() 
    //do your work
    }
      

  2.   

    B
    {
      return CreateThread(A);
    }C
    {
      HANDLE h=B();
      WaitForSingleObject(h);
      GetExitCodeThread(h);
    }
      

  3.   

    m_hFunAEventKill= CreateEvent(NULL, TRUE, FALSE, NULL);
        //do your work
        SetEvent(m_hFunAEventKill);
        return x;