It is written on Wikipedia: (https://en.wikipedia.org/wiki/Thermal_energy)
The thermal energy of a system scales with its size and is therefore an extensive property. It is not a state function of the system unless the system has been constructed so that all changes in internal energy are due to changes in thermal energy, as a result of heat transfer (not work). Otherwise thermal energy is dependent on the way or method by which the system attained its temperature.
My question is: Why thermal energy is dependent on the way or method by which the system attained its temperature? You only need to give me an example proving that. Thanks in advance.