added mutex for schedular loop