thread.cc seg fault bug fixed