A machine for the thermal treatment of liquid and semi-liquid food products includes at least two tanks for containing respective products to be subjected to the thermal treatment, at least one dispenser for dispensing the product contained in said tanks, at least one stirrer mounted inside each tank for mixing the product contained therein, and thermal treatment means operatively acting on the products contained in the containers. The thermal treatment means includes at least one circuit for circulation of an operating fluid and two first heat exchangers operating according to a thermodynamic cycle each of the two heat exchangers being associated with a respective tank. The thermal treatment means is configured to implement at least one operating mode of removing heat from the respective tank by one heat exchanger and simultaneously transferring heat to the respective tank by the other heat exchanger.