Lets say a function,
int fun(){
static int a = 10;
a = a+1;
return a;
}
The above function is returning a integer value,
//Without thread obtaining return value
#include<iostream>
int main()
{
int var = 0;
var = fun();
std::cout << "The value " << value << std::endl;
return 0;
}
Now is there any possible way to get the returned value when invoked by C++11 thread,
//Using thread
#include<iostream>
#include<thread>
int main()
{
std::thread t1(fun);//Invoking thread
//How to obtain the return value of the thread ?
return 0;
}
Thanks!
Aucun commentaire:
Enregistrer un commentaire