adding locks before notifies in Scheduler to stop deadlocks