What's a better way to start a thread, _beginthread
, _beginthreadx
or CreateThread
?
I'm trying to determine what are the advantages/disadvantages of _beginthread
, _beginthreadex
and CreateThread
. All of these functions return a thread handle to a newly created thread, I already know that CreateThread provides a little extra information when an error occurs (it can be checked by calling GetLastError
)... but what are some things I should consider when I'm using these functions?
I'm working with a windows application, so cross-platform compatibility is already out of the question.
I have gone through the msdn documentation and I just can't understand, for example, why anybody would decide to use _beginthread instead of CreateThread or vice versa.
Cheers!
Update:
OK, thanks for all the info, I've also read in a couple of places that I can't call WaitForSingleObject()
if I used _beginthread()
, but if I call _endthread()
in the thread shouldn't that work? What's the deal there?