Avoid failing sometimes in the test_parallel_wait

Control flow by thread queue instead of sleep