pthread_join and exit added