2

I was revising my codes when doing a project that I developed when I started coding in C/C++.

It's about threading. In the tutorials I read (which were from 2006) they said that, when developing for Windows, one could use CreateThread() to create threads. Is Using this function better than using std::thread?

Is it faster also?

78dtat78da
  • 112
  • 1
  • 9

1 Answers1

1

In applications that load the CRT (as most C/C++ are) you can't use CreateThread, as per spec:

A thread in an executable that calls the C run-time library (CRT) should use the _beginthreadex and _endthreadex functions for thread management rather than CreateThread and ExitThread; this requires the use of the multithreaded version of the CRT. If a thread created using CreateThread calls the CRT, the CRT may terminate the process in low-memory conditions.

std::thread on the other hand will do the right thing.

Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569