Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- first condition:
- Thread 1 Waits
- Thread 2 Notifies
- second condition:
- Thread 2 Notifies
- Thread 1 Should not wait and continue normal execution.
- Thread 1:
- lock(x);
- if(!signaled)
- {
- unlock(x); // ****************************
- // still small gap, how to avoid?
- cv.wait();
- signaled = false;
- }
- else unlock(x);
- Thread 2:
- lock(x);
- signaled = true;
- cv.notify();
- unlock(x);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement