At the ressurection, if God is going to reunite body and
soul, which body will the reincarnated soul inhabit?
This
question was asked long ago in the Zohar.
"Rabbi
Yosi answered: 'Those bodies which were unworthy and did not achieve their purpose will be regarded as though they had not
been... [i.e. they won't be resurrected]. Rabbi Yitzchak [disagreed and] said: For such bodies the Holy One will provide other
spirits, and if found worthy they will obtain an abiding in the world, but if not, they will be ashes under the feet of the
righteous." (I Zohar 131a; cf. Zohar
II 105b)
The answer, then, is that, basically,
a soul is resurrected with the body it completed its final tikkun (correction) with, i.e. the one that was "worthy."