added checks for program status when threads gain locks