...
- Replaced the sleep with an active wait loop (a.k.a., polling), i.e., wait until a condition has been met before moving on
- Use external synchronization, i.e., use existing class notification mechanism to know it has reached a certain state before continuing
- Refactor the code under test to eliminate concurrency
- Use external dependency calls or side-effects as synchronization points in the tests