When bodies are in thermal equilibrium, the temperature remains constant. Since, internal energy is a function of temperature (ΔT) , (ΔU=21fΔT) ,
hence for isothermal change ΔT=0 ,
therefore ΔU=0
Hence, internal energies of the two bodies will be equal.