Use a condition variable instead of a queue