Runaway electrons (REs) generated during disruptions pose a significant safety threat to tokamaks, as they can melt and damage the plasma-facing components (PFCs). Therefore, studying RE behavior is crucial for fusion devices. The interaction between REs and the first wall/PFCs results in the emission of high-energy X-rays, known as bremsstrahlung. To investigate RE behavior, it is necessary to quantitatively evaluate the emission of hard X-rays. A real-time hard X-ray spectrometer, utilizing a LaBr3 detector, has been successfully developed for studying REs on the HL-2M tokamak. This spectrometer has a counting rate capability reaching 3 MHz, with an energy resolution of 3.3% at 662 keV (137Cs). The time resolution for energy spectrums is as short as 1 ms. During the HL-2M discharge, observations were made on the hard X-ray energy spectrum, and by analyzing the spectrum within the energy range of 250 keV to 750 keV, the temperature of the corresponding REs was deduced.