Fixed use of mutex and condition, which corrects a long-standing rare