I want to define two of std::thread in my function, than join() them multiple times in a loop. I googled for it but I only found questions like "C++ multiple joining on the same function".
Code:
void Func()
{
thread t1 {ThreadFunc1};
thread t2 {ThreadFunc2};
while(true)
{
if(t1.joinable())
t1.join();
if(t2.joinable())
t2.join();
// Do someting else.
}
}
As I expected, the threads are running just once at the first cycle. I want to make it very fast. I wonder if I can reset them or 'make it joinable' again. Do you have any solutions?
Thanks!
Aucun commentaire:
Enregistrer un commentaire