Hello.
There is a hot discussion on one Russian developers forum about correct threads creation. _beginthreadex is more correct way because it initializes CRT for the newly created thread.
But there is one great "BUT"!!!
For example we have any callback function which uses CRT (like an exported function from dll). This function could be invoked from any thread including threads, that was created via CreateThread (i.e. CRT was not initialized for this thread). So this call can cause an undefined behaviour! But there is not way to determine CRT initialization status and initialize CRT manually ![]()
It looks like a potential source of great troubles.

CreateThread vs _beginthreadex
Stéphane Beauchemin
Shajeel
Adam Anderly
I CAN`T BELIEVE!
I asked this question on many forums. But I still have no an answer!
I was right, it looks like a potential source of great troubles.
Jorge_242
That looks like an old artifact to me. There's no longer any difference between the previously multithreaded and singlethreaded CRT libraries. In either case, the documentation should be clearer on what the actual difference is. Send a mail to the Platform SDK team, or bump this thread long enough for them to notice the argument.
GLutz78
If you could dig into the crt\src\threadex.c file, you can see how _beginthreadex has been written. It's internally calling CreateThread function.
You can check this blog post by Visual C++ Team to know more about CRT initialization.
3Nu
But 00.01% has mantained. I think this value is much greater because here works simply logic: "If CreateThread function is exists and documented then somebody will call it!". And then troubles are quite possible.
Kzin
Eventhough it is not necessary to state a requirement for multithreaded runtime libraries for VC 2005, I assume that the need for _beginthread and _endthread functions still exist for the reason stated.
n00bie
Anyway can I be sure that my exported function from dll will be safe independently of thread where it will work Is there any guarantee
Burnt1ce
Its not clear. _beginthreadex and _beginthread wrap CreateThread, but do some other stuff. You can step through _beginthreadex since the CRT sources are shipped with Visual Studio. It calls an internal function _threadstart (which wraps your real thread entry procedure), and this function touches the "thread local store" (TLS), making that the point of possible behavior differences. I don't see anything major going on here though: I see locale-related stuff, and I also see a case where special FP initialization occurs, but I don't know what scenario requires them.
If you have differences between calling _beginthreadex or CreateThread, I would look to see if they have anything to do with the things that the things that happen in _threadstart.
Brian
MNDANG
Ok. Thanks.
Joanne Sobryan
@lex(is)
There are plenty of good CRT replacements out there. I don't really see any use for avoiding it in just one thread, though. Again; an odd piece of information shared by MSDN, and if the multithreaded/singlethreaded CRT aspect is the only one, it seems like a complete waste of bandwidth.
Adam Tappis - IMGroup
But MSDN says:
It is not for no particular reason, Isn`t it
wycleft