2

I read on stackoverflow that when using the Windows API to start a thread _beginthreadex() is preferred over CreateThread().

I am creating threads like this using 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.

How do I do this with _beginthreadex() rather than CreateThread()?

Can anyone post an example?

Richard Chambers
  • 16,643
  • 4
  • 81
  • 106

1 Answers1

1
_beginthreadex(NULL, 0, ThreadFunc, NULL,0,NULL); 

should do the trick for you. You can ignore those additional parameters as most of those are optional.

The following SO links might be useful for you:

Windows threading: _beginthread vs _beginthreadex vs CreateThread C++

_beginthread vs CreateThread

Community
  • 1
  • 1
Jay
  • 24,173
  • 25
  • 93
  • 141