I was looking on some forum and there it is recommended to use these in pair. Also there are lots of caveats for using CreateThread() API with C/C++ runtime library.
Also somewhere It is said that never to use _beginthreadex() with WIN32 API.
Which has created lots of doubt for me!
Question:
Please let me know, Is it correct to use any function from c/c++ runtime function inside CreateThread() start function?
Always use _beginthreadex(). FYI, I have never used _endthreadex(). It is not necessary. The CRT will call it for you automatically once the thread main function exits. Search for _beginthreadex() in MSDN and you'll get all the details.
No, the "issue" with CreateThread() is either that certain CRT data structures are not initialized or are not freed at the end (don't recall which one right now). I believe these structures are related to TLS (Thread Local Storage) and therefore most of the time you just don't even notice because very few actually use TLS.