Spectrum sensing is a key enabling technology of cognitive radio. Reliable detection increases access opportunity to temporarily unused bands and prevents harmful interference to the licensed users. Due to the receiver noise, signal attenuation, and multi-path fading effect, however, it is usually not possible to determine the existence of primary signal with absolute certainty. Without the information of primary user activity, Neyman-Pearson criterion has been commonly used to minimize the missed detection probability for a given false alarm rate. In this paper, we assume that the traffic statistic of primary system is logged into the radio environment map (REM) and can be accessed by the secondary system. Considering sensing errors, Bayes criterion is adopted for total utility maximization of primary and secondary systems. The threshold of energy detector is adapted according to the utility values and a priori information from REM, i.e., both false alarm and detection probabilities are dynamically adjusted.