bug fix for thr_join() and thr_exit()