如题!

解决方案 »

  1.   

    windows核心编程上说 让线程自己返回时最好的
    建议让线程处理完后,自己返回
      

  2.   

    另外 建议用_beginthreadex 来创建线程,而不是CreateThread
      

  3.   

    我创建线程和使用线程的情况如下:
    一:创建线程:
    g_TheadInfo.hGetDataThread=::CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)GetDataThread,&g_TheadInfor,CREATE_SUSPENDED ,&ThreadID);
      
    UINT GetDataThread(LPVOID lpParam)
    {
        CTheadInfo *pThreadInfo=(CTheadInfo*)lpParam;    int nFun=0;
        while( pThreadInfo->bExitThread==FALSE)
        {
            pThreadInfo->TheFun();
        }
        return 0;
    }
    二:当点击按钮时执行如下代码:
    int n=::ResumeThread(g_TheadInfo.hGetDataThread);
             if(n>=2)for(int i=1;i<n;i++)
                ::ResumeThread(g_TheadInfo.hGetDataThread);
      

  4.   

    _beginthreadex 来创建线程,而不是CreateThread,为什么?能解析一下吗?
    还有,俺知道线程池可以限定资源,但是,怎样创建?谢谢!
      

  5.   

    A thread in an executable that calls the C run-time library (CRT) should use the _beginthreadex and _endthreadex functions for thread management rather than CreateThread and ExitThread; this requires the use of the multi-threaded version of the CRT. If a thread created using CreateThread calls the CRT, the CRT may terminate the process in low-memory conditions.
      

  6.   

    为什么很多地方这么说?我倒是持相反的看法。尽量使用WINDOWS API CreateThread创建线程。
      

  7.   


    请看8楼说的,如果线程里要调用C运行时库函数,建议使用_beginthreadex()核心编程里还提到 如果用CreateThread(),会造成资源释放不完全
      

  8.   

    问题解决了。俺直接在线程执行完后return 0就可以了.谢谢各位.