Let $M(X, mathcal{A}, mu)$ be the ring of real-valued measurable functions on a measure space $(X, mathcal{A}, mu)$. In this paper, we characterize the maximal ideals in the rings of real measurable functions and as a consequence, we determine when $M(X, mathcal{A}, mu)$ is a hereditary ring.