improve pthread_exit synchronization with functions targeting tid