Apply torque to a shaft and every cross section rotates slightly relative to its neighbours. The material resists through shear stress, which is zero at the centre and rises in direct proportion to radius, reaching its peak at the outer surface. A point on the surface is dragged around the circumference while its neighbour along the shaft stays put, and that sliding is exactly what shear stress measures. Because the middle of a solid shaft carries almost no stress, it contributes little strength: it is mostly there for the ride. This single fact explains the existence of tubular shafts, from bicycle frames to aircraft propeller shafts, wherever weight matters.
The polar second moment of area, J, governs both stress and twist. For a tube it is pi over 32 times the difference of the fourth powers of the outside and inside diameters. Fourth powers reward material placed at large radius handsomely. Take a solid 50 mm shaft and bore a 40 mm hole through it: you remove 64 percent of the material but keep about 59 percent of the J, so the stress rises by less than 70 percent while the weight falls by nearly two thirds. Thin walls cannot be pushed forever, because a very thin tube can buckle locally or ovalise, but within sensible proportions the hollow shaft is one of engineerings best bargains. The same fourth power logic is why driveshafts are large diameter tubes rather than slim solid bars.
A shaft can pass the stress check and still fail its job by twisting too much. Excess twist upsets gear meshing, spoils timing between the ends of a long shaft, and lets torsional vibration build. The angle of twist is torque times length divided by G times J, where G, the shear modulus, is about 79 GPa for steel. Long shafts are the problem: twist accumulates with every metre. Machine tool and marine practice therefore limit twist per unit length, often to a fraction of a degree per metre, and that limit frequently sizes the shaft rather than the stress limit. When you check a shaft, check both numbers: the shear stress against the materials allowable, and the twist against what the driven machine can tolerate.