I want one thread to be constantly updating a variable and have a second thread respond when the variable is a certain value. The second thread isn't responding.
One thread simulates a one-second click. The other thread is waiting for the third click. The clicking is happening, but the second thread doesn't seem to be detecting when the variable equals 3.
The way I understand it, condition_variable.wait() constantly checks for the condition to be true. Maybe I'm missing something about how that works.
Output:
1 2 3 4 5 6
click number 1
click number 2
click number 3
click number 4
click number 5
...
By the way: Even with notify you may miss click_counter == 3 because the scheduling of the thread is not predictable. So it might happen that click_counter is already 4 when click_listener() gets its timeslice.
And you should rather consider to use sleep instead of the loop. See: