I have C ++ code with two threads. After event “A” in thread 2, thread 1 must be paused (suspended), several more tasks must be performed in thread 2 (for example, event “B”), and finally, thread 1 must 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; }
Vigo
source share