using namespace std;
bool flag = false;
void* doStuff(void t)
//does lots of stuff
flag = true;
//does lots of stuff. takes long time to do that
pthread_t threadCall(int t)
rc = pthread_create(&threads, NULL, doStuff, (void *)t);
cout << "Error:unable to create thread," << rc << endl;
int t =10;
pthread_t thread= threadCall(t);
//does some function calls
//do some stuff when flag gets true.
above is my code. I want to wait in main thread for flag to be set true by another thread as you can see here doStuff() function set the flag true. In main thread, statement while(!flag); waits in busy waiting until flag get true.
Is there any other way to wait in main thread except this busy waiting.
Thanks in advance