Stars shine through a process called nuclear fusion, specifically hydrogen fusion, which occurs in their cores. This fusion process involves the conversion of hydrogen atoms into helium, releasing an enormous amount of energy in the form of light and heat.
The reason stars do not burn out quickly is because of a delicate balance between two forces: gravity and the energy generated by nuclear fusion. Gravity pulls the mass of the star inward, trying to compress it, while nuclear fusion exerts an outward pressure that resists the collapse caused by gravity.
In the core of a star, the immense gravitational pressure and temperature allow hydrogen atoms to collide with enough energy to overcome their mutual electrostatic repulsion. This leads to the fusion of hydrogen nuclei into helium, releasing energy in the process. The released energy creates an outward pressure that counteracts the force of gravity, maintaining the star's stability.
The rate at which a star burns its fuel depends on its mass. More massive stars have higher core temperatures and pressures, enabling them to burn fuel more rapidly. Consequently, they have shorter lifespans compared to less massive stars.
While stars do eventually exhaust their nuclear fuel, leading to changes in their structure and behavior, the timescales for this process are on the order of millions to billions of years for main-sequence stars like the Sun. After the exhaustion of fuel, the fate of a star depends on its mass. Smaller stars, like red dwarfs, can continue to burn for trillions of years as they transition to other phases. Larger stars undergo more dramatic transformations, such as supernovae or the formation of white dwarfs, neutron stars, or even black holes.
In summary, stars shine through the balance between gravity and nuclear fusion. As long as this balance is maintained, stars can continue to radiate light and heat for long periods of time.