(Merge 3.2) Issue #12096: Fix a race condition in
test_threading.test_waitfor(). Patch written by Charles-François Natali.