Why is my thread locked?