added the pthread_join(), and the main thread will wait all the threads to be finished