fixed memory leaked caused by non-joining pthreads