This particle-in-cell simulation study finds that the system of a long relativistic electron beam passing through an overdense plasma can produce high harmonic terahertz electromagnetic radiation. In this process, the electron beam is self-modulated to create a periodic electromagnetic structure which will resonate with the plasma wakefield and excite the electromagnetic instability in the nonlinear stage of the self-modulation. The study also finds that when the radiation is achieved, the self-modulated electron beam will be destroyed due to the self-consistent interaction among the radiation, the electron beam, and the plasma. Meanwhile, the radiation will gradually attenuate, which also coincides with the physical explanation of the radiation.