@JohnRennie have a very fundamental doubt. A black body can be assumed as a cavity with a small hole with radiation leaking out of it. As the temperature of the black body is increased we can assume the the charge particles, electrons, on the metal surface will behave as harmonic oscillators and the energy of the harmonic oscillation will be equal to the energy density of the radiation inside the cavity at thermal equilibrium.
My doubt is that at thermal equilibrium, the cavity(assuming it to be uniform) will have a uniform temperature. Since the oscillations of the charged particles is du…