Try using `Thread.pass` instead of condition variables for waiting.