None of these answers seems to explain correctly why the Sun differs from a nuclear bomb.
The reason is that any star, including the Sun, acts as a thermostat. If the Sun were to produce more energy than it can radiate away, the energy thus freed would make it hotter; a hot gas expands, and simultaneously cools. Both factors (lower densities and lower temperatures) would then contribute to reducing the rate of nuclear energy generation.
Conversely, if the Sun were to produce less energy than it radiates away, it would then contract; in a contractcontraction temperature increases, and both factors (larger densities and higher temperatures) lead to an increase in the production of nuclear energy, thusly restoring once again equilibrium.
This is exactly the behaviour of a thermostat. It is often said that the structure of a star is dictated not by the nuclear sources involved, but by the extent of its envelope. The reason for this has been described above: the rate of nuclear energy generation simply adapts itself to what is demanded by the stars' energy transfer processes.
On the other hand, matter inside a nuclear bomb cannot expand and cool if energy is produced in excess; actually, the exact opposite is true: fissionable matter is disposed in such a way that the initial fusion explosion heats and compresses the fusion material to make sure that fusion reaction can procede without impediments. And this is exactly the opposite of the interiors of a star.
This process is described just about anywhere, including Martin Schwarzschild's now obsolete book, Structure and evolution of the stars, and also online, see the paragraph entitled A stellar thermostat here-