I have a C++ code with two threads in it. After an event 'A' in thread 2, thread 1 should be paused(suspended), some more tasks are to be executed in thread 2 (say event 'B')and finally thread 1 should be resumed. Is there any way to do this?
My code looks something like this:
HANDLE C;
DWORD WINAPI A (LPVOID in)
{
while(1){
// some operation
}
return 0;
}
DWORD WINAPI B (LPVOID in)
{
while(1){
//Event A occurs here
SuspendThread (C);
//Event B occurs here
ResumeThread (C);
}
return 0;
}
int main()
{
C = CreateThread (NULL, 0, A, NULL, 0, NULL);
CreateThread (NULL, 0, B, NULL, 0, NULL);
return 0;
}