Possible improvement to how the thread waits