Implemented priority scheduler.