Search code examples
c++multithreadingprocessbeginthreadbeginthreadex

Multithreading: thread or process.h - C++


I started studying multithreading. And I've found 2 ways to use it ic C++. First is by thread

#include <thread>
...
std::thread t(function);
<< some code>> 
t.join(); //(or detach)

And second is by process

#include <process.h>
...
_beginthreadex('bunch of parameters');
<< some code >>
_endthreadex()

So what, if anything, is the difference? And if there is a difference, when should one be used instead of the other?


Solution

  • Stick with the first and standard way in C++ to create thread, i.e, using std::thread.

    The second is Microsoft specific. I doubt that anyone would use it nowadays. See this: https://www.quora.com/When-do-we-write-include-process-h/answer/Sergey-Zubkov-1