This is from Schroeder's An Introduction to Thermal Physics:
Let A and B be a system both with a concave-up entropy-energy graph. The systems will achieve thermal equilibrium when they are at the same temperature. Usually, however, the equilibrium will not be stable. Any small flow of energy from B to A will cause the temperature of B to increase while the temperature of A decreases. We then get a run-away effect, as more and more energy spontaneously flows from B to A. And if the initial fluctuation results in energy flowing from A to B, the run-away effect goes in the opposite direction.
If B is a large "reservoir" whose temperature doesn't change significantly when it absorbs or emits energy, then again any small transfer of energy from B to A will result in A becoming colder than B so we get a run-away effect. The only way for the equilibrium to be stable is if system B is "normal" and sufficiently small (more precisely, has a sufficiently small heat capacity) that a spontaneous transfer of energy from B to A causes B to cool off more than A does. Then A will become a bit hotter than B and the energy will spontaneously flow back.
I don't understand...Why would there be a run-away effect? When there's a flow of energy from B to A, the temperature of B increases, which by then means the internal energy of B increases as well. But how can B has its internal energy increases when it is losing some of its energy??