Thermodynamics for black strings and p-branes