dimanche 25 septembre 2016

std::thread move constructor

I recently looked at this std::thread reference.

For the move constructor it says:

thread( thread&& other ); 

Move constructor. Constructs the thread object to represent the thread of execution that was represented by other. After this call other no longer represents a thread of execution.

Also, in the example below there are these lines:

int n=0;
std::thread t3(f2, n);
std::thread t4(std::move(t3)); // t4 is now running f2(). t3 is no longer a thread

What I don't understand is what exactly happens with thread t3 and t4? Does t4 waits until t3 finish its execution?

Aucun commentaire:

Enregistrer un commentaire