change the code for pthread