Updated 1997 by PEG.
Updated 1992 by SIC.
Original by Robert Firth.
These are the props. You own a barn, 40m long, with automatic doors at either end, that can be opened and closed simultaneously by a switch. You also have a pole, 80m long, which of course won't fit in the barn.
Now someone takes the pole and tries to run (at nearly the speed of light) through the barn with the pole horizontal. Special Relativity (SR) says that a moving object is contracted in the direction of motion: this is called the Lorentz Contraction. So, if the pole is set in motion lengthwise, then it will contract in the reference frame of a stationary observer.
You are that observer, sitting on the barn roof. You see the pole coming towards you, and it has contracted to a bit less than 40m, in your reference frame. (Does it actually look shorter to you? See Can You See the Lorentz-Fitzgerald Contraction? for the surprising answer. But in any case, you would measure its length as a bit less than 40m.)
So, as the pole passes through the barn, there is an instant when it is completely within the barn. At that instant, you close both doors simultaneously, with your switch. Of course, you open them again pretty quickly, but at least momentarily you had the contracted pole shut up in your barn. The runner emerges from the far door unscathed.
But consider the problem from the point of view of the runner. She will regard the pole as stationary, and the barn as approaching at high speed. In this reference frame, the pole is still 80m long, and the barn is less than 20 meters long. Surely the runner is in trouble if the doors close while she is inside. The pole is sure to get caught.
Well does the pole get caught in the door or doesn't it? You can't have it both ways. This is the "Barn-pole paradox." The answer is buried in the misuse of the word "simultaneously" back in the first sentence of the story. In SR, that events separated in space that appear simultaneous in one frame of reference need not appear simultaneous in another frame of reference. The closing doors are two such separate events.
SR explains that the two doors are never closed at the same time in the runner's frame of reference. So there is always room for the pole. In fact, the Lorentz transformation for time is
t'=(t-v*x/c2)/sqrt(1-v2/c2)
It's the v*x term in the numerator that causes the mischief here. In the runner's frame the further event (larger x) happens earlier. The far door is closed first. It opens before she gets there, and the near door closes behind her. Safe again -- either way you look at it, provided you remember that simultaneity is not a constant of physics.
If the doors are kept shut the rod will obviously smash into the barn door at one end. If the door withstands this the leading end of the rod will come to rest in the frame of reference of the stationary observer. There can be no such thing as a rigid rod in relativity so the trailing end will not stop immediately and the rod will be compressed beyond the amount it was Lorentz contracted. If it does not explode under the strain and it is sufficiently elastic it will come to rest and start to spring back to its natural shape but since it is too big for the barn the other end is now going to crash into the back door and the rod will be trapped in a compressed state inside the barn.
References: Taylor and Wheeler's Spacetime Physics is the classic. Feynman's Lectures are interesting as well.