Scientists in Earthquake-prone California are working on a series of sensors that can detect an earthquake and give a warning a few seconds before an earthquake hits. This would give enough time to get children under their desks, or set off automatic shut-offs for gas pipelines.
An earthquake sends out two waves of energy. The P-wave is low energy, but moves quickly from the epicenter. The S-wave is what causes the shaking, and it moves slower. The idea is to detect the P-wave, and issue the warning before the S-wave arrives. Depending on the distance from the epicenter, this could result in several seconds of warning. At the epicenter, the warning would come 4 seconds after the quake, but 37 miles away, the warning would come 16 seconds before the shaking starts.