[This page should at some point in time be merged with Lightning, since it´s kind of the same page]
A lightning bolt is a visual that damages entities within a 4 block radius of the struck block and creates an explosion with an ExplosionPower of 0, additionally setting objects on fire. In the game code, there is a flag on the Explosion class's code that determines whether there will be fire from the explosion.
Lightning has a state, which defaults to 2 and decrements per entity logic update tick.
When the state is at 2, it plays the "ambient.weather.thunder" and "ambient.weather.thunder" sounds. When it is lower than 0, its living time is decremented and its state set to 1. This is repeated until its living time is 0, when it is killed.