How to fix a messed up thread