thread error waiting fix