【问题标题】:How to start a thread with _beginthreadex?如何使用 _beginthreadex 启动线程?
【发布时间】:2012-03-12 13:04:52
【问题描述】:

我在 stackoverflow 上读到,当使用 Windows API 启动线程时,_beginthreadex() 优于 CreateThread()

我正在使用CreateThread() 创建这样的线程:

DWORD WINAPI ThreadFunc(void* data)
{
    // code for the thread functionality.
}

 HANDLE Multicast = CreateThread(NULL, 0, ThreadFunc, NULL, 0, NULL);
 if (Multicast) { } // thread started successfully.

如何使用 _beginthreadex() 而不是 CreateThread() 来做到这一点?

谁能发个例子?

【问题讨论】:

    标签: c multithreading winapi


    【解决方案1】:
    _beginthreadex(NULL, 0, ThreadFunc, NULL,0,NULL); 
    

    应该为您解决问题。您可以忽略这些附加参数,因为其中大部分是可选的。

    以下 SO 链接可能对您有用:

    Windows threading: _beginthread vs _beginthreadex vs CreateThread C++

    _beginthread vs CreateThread

    【讨论】:

      猜你喜欢
      • 2015-12-16
      • 1970-01-01
      • 1970-01-01
      • 2010-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-16
      • 1970-01-01
      相关资源
      最近更新 更多