Take the queue lock before notifying all the event conditions, fixes crash when running tests or waiting on events