Increase the timeout tolerance if TEST_HAS_SANITIZERS is set, similarly
to how it's done in a couple other tests.
Use std::this_thread::yield(); instead of busylooping. When multiple
threads are busylooping, it's plausible that not all threads even get
started running before the timeout runs out.
This makes the threading tests succeed if run in Windows runners on
Github Actions.
Can you add the comment of the other similar tests (See D131484)