Updates to use locks and conditions.