Firefly flashes are actually mating signals. Male fireflies cruise the evening air, flashing their lanterns in a pattern characteristic of their species, looking for females of their own kind.
The males of some species flash with a slow glow lasting several seconds; others flicker more than 40 times per second. There are more than 2,000 firefly species worldwide, each with a particular male flash pattern.
The female firefly emerges from her burrow after sunset and waits on the ground. When she detects the flash of a male of her species, the female flashes back in a characteristic female pattern.
Exchanging flashes, male and female find each other and mate. Then the female returns to her burrow, and the male returns to the air. Sometimes, however, the male does not return to the air, because he is eaten by the female.
Female fireflies of some species eat male fireflies of other species. They attract these males by detecting their flash patterns and sending a return flash pattern that imitates a female of the appropriate species. Some of these duplicitous insects have a repertoire of five or more different flash patterns.
So, every time a male firefly sees a responsive female flash in the grass, he faces a life and death dilemma. He could hesitate, and risk losing out to another male in the race to mate, or rush in and risk being eaten alive.