A machine for the thermal treatment of liquid and semi-liquid food products comprises: at least two tanks (3A,3B) for containing respective products to be subjected to the thermal treatment, at least one dispenser (4) for dispensing the product contained in said tanks (3A,3B), at least one stirrer (5) mounted inside each tank (3A,3B) for mixing the product contained therein, thermal treatment means (6) operatively acting on the products contained in the containers (3A,3B) the machine (1) being characterized in that the thermal treatment means (6) comprise at least one circuit (7) for circulation of an operating fluid and at least two first heat exchangers (8A,8B) operating according to a thermodynamic cycle each of the two first heat exchangers (8A,8B) being associated with a respective tank (3A,3B) said thermal treatment means (6) being configured in such a way as to implement at least one operating mode of removing heat from the respective tank (3A,3B) by means of one first heat exchanger (8A) and simultaneously transferring heat to the respective tank (3B) by means of the other first heat exchanger (8B).