Use IsAlive to wait for threads to end