在MSDN中说到:当线程中用到C-runtime库中的函数时,得用_beginthread或用_beginthreadex来创建线程。
我得问题是:当该线程中间接用到C-runtime库中得函数时,即被该线程函数调用得函数中用到C-runtime库中得函数时,是否也应该用_beginthread或_beginthreadex来创建一个新得线程?

解决方案 »

  1.   

    总共就两个函数可以建线程,_beginthread和CreateThread(),不用这个就用另一个好了.这么咬文嚼字的做什么?
      

  2.   

    内存泄漏和你调哪个函数起线程无关.可能的地方是:1. 用_beginthread()起线程,应该用_endthread()关线程,却误用了TerminateThread();反之亦然.2. 线程内部因设计问题造成的泄漏.3. 其它可能原因.
      

  3.   

    Zark(金陵五月):
    下面是引自MSDN的原话:
    A thread that uses functions from the C run-time libraries should use the beginthread and endthread C run-time functions for thread management rather than CreateThread and ExitThread. Failure to do so results in small memory leaks when ExitThread is called. Note   For an executable file linked with LIBCMT.LIB, do not call the Win32 ExitThread API; this prevents the run-time system from reclaiming allocated resources. _endthread and _endthreadex reclaim allocated thread resources and then call ExitThread._beginthread 函数初始化某些 C 运行时库变量。只有在线程中使用 C 运行时库时,这一点才很重要。以上三段话表明:CreateThread()、ExitThread()和_beginthread()、_endthread()的行为是有明显却别的!而且你在回答我提出的问题时偷还了概念。我得问题本身是独立于你所指出的三个主观错误可能造成的问题的。