lock and unlock scheduler tasks