fix thread exit bug and double free bug