Sauropods, the type of huge dinosaurs including Apatosaurus, Brachiosaurus and Diplodocus, had very long necks and tails. In 1989, the biomechanics expert R. McNeill Alexander proposed that they used their tails as whips. He suggested this was not so much for defence, but to attract mates with the cracking sound.
Operating a whip generates a wave, which accelerates towards the tip because a whip is thinner at that end. The crack of a whip is really a small sonic boom, caused by the wave’s exceeding the speed of sound. Now, a Microsoft research leader Nathan Myhrvold has run computer simulations of a 13-metre sauropod tail, showing that a wave started at the base could indeed break the sound barrier. Also, he examined eight fossil sauropods, and found that tail vertebrae are longest a quarter of the way from the base, a known stress point in a whip - good design. Indeed, half of them had possible stress injuries there, so Myhrvold believes these were the males, which would support the mate attraction theory.
Source: C. Seife, New Scientist 156(2110):27, 29 November 1997; citing Paleobiology 23:353.